I want to show the status of my contract, both of which are declared as follows:
public enum RentStatus
{
[Description("Preparation description")]
Preparation,
[Description("Active description")]
Active,
[Description("Rented to people")]
Rented
}
public class RentContract
{
public int RentContractId { get; set; }
public virtual Premise Premise { get; set; }
public double Price { get; set; }
public RentStatus Status { get; set; }
}
My current XAML that is wrong
<ComboBox x:Name="RentStatusComboBox"
ItemsSource="{Binding RentContract}"
Grid.Row="2"
Grid.Column="1"
HorizontalAlignment="Stretch"
SelectedItem="{Binding RentContract.Status}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Description}" Padding="0" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
I've seen several solutions that use Converters and methods, but I don't think those are able to allow for databinding so that my entity is updated when I change the status in my UI.
Edit: Following this excellent blogpost solved my issue.