XAML:
<ComboBox Height="27" Margin="124,0,30,116" Name="cbProductDefaultVatRate" VerticalAlignment="Bottom" ItemsSource="{Binding}">
<ComboBox.ItemTemplate>
<DataTemplate>
<Label Height="26" Content="{Binding Path=Value}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
Set Data for cbProductDefaultVatRate.Items (Type - VatRate):
private void ShowAllVatRates()
{
cbProductDefaultVatRate.Items.Clear();
cbProductDefaultVatRate.ItemsSource = new VatRateRepository().GetAll();
}
Similarly, I defined property:
private Product SelectedProduct
{
get; set;
}
The Product contains VatRate:
SelectedProduct.DefaultVatRate
How to set SelectedItem equal SelectedProduct.DefaultVatRate? I tried:
cbProductDefaultVatRate.SelectedItem = SelectedProduct.DefaultVatRate;
But it does not work.
Thank you for answers!