Hello,
I am failing in achieving a very simple functionality from a WPF ComboBox.
My ComboBox needs to list a collection of values. This works fine. The value id is also saved succesfully in the database. The problem is that when i want to open the window in edit mode, the combo stays empty. Here is the code :
<ComboBox Height="28"
HorizontalContentAlignment="Center"
Name="cmbActivity"
ItemsSource="{Binding Path=Unit.UnitActivities}"
SelectedValuePath="Id"
SelectedValue="{Binding Path=UnitActivityId}"
Style="{StaticResource comboBoxInError}"
Width="200"
Margin="6"
HorizontalAlignment="Left">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock FlowDirection="LeftToRight" Text="{Binding Path=ActivityTime.Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBox.SelectedItem>
<Binding ElementName="cmbActivity" Path="UnitActivityId" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<ExceptionValidationRule />
<val:NotEmptyValidationRule />
<val:UnitResTimeOverlapValidationRule />
</Binding.ValidationRules>
</Binding>
</ComboBox.SelectedItem>
</ComboBox>
I understand my problem is somewhere in the SelectedItem section, but i just could not figure where and why.
Please help..
Thanks,