C#C
C#6mo ago
enrico11011

✅ Avalonia - is there a way to cast/convert a value before it's bound?

I've got a combo box in my UI that looks like so:
<ComboBox PlaceholderText="Material" 
          HorizontalAlignment="Stretch" 
          ItemsSource="{Binding Materials}" 
          SelectedItem="{Binding NewTransferFormLine.MaterialId}" />


Materials is of type ObservableCollection<Material>, and I would like to bind the int ID of the SelectedItem (i.e Material.Id) to NewTransferFormLine.MaterialID, which is also an int. Is there a way to do this cast/conversion cleanly within avalonia or do I have to get into the setter and do it there?
Was this page helpful?