I have WPF combo based dropdown list that can have 4 items to the max.Out of these there is a last item named "Other"(hard-coded) which allows user to select a new resource.When user selects the new resource it is updated in the dropdown list(still 4 items) and accordingly based on the selected resource, our items in the UI application are updated.It also shows the selected item in UI. The problem am facing can be described as:
Suppose i have the following resources in the drop-down list:
Item 1
Item 2
Item 3
Other
Now when i select 'Other', a dialog is shown to select the resource. From this dialog, i again select 'Item1'(First item in the dropdown list).Now in UI, it still shows the selected item as 'Other'. I investigated and found the root cause as: In the XAML, the dropdown control's item source is bounded to an observable collection named "ResourceList". Whenever a new resource is selected in UI it gets added to this collection and whenever i make a "CHANGE" to this collection only then it is reflected in UI otherwise NOT.
XAML Code:
<inputToolkit:UxDropDown x:Name="cmbResourceList"
MaxWidth="150"
Margin="8 0"
HorizontalAlignment="Left"
AutomationProperties.AutomationId="cmbResourceListForTask"
Cursor="Hand"
FontSize="{StaticResource TaskListHeaderFontSize}"
FontWeight="Bold"
ItemsSource="{Binding ResourceList}"
SelectedValue="{Binding Path=SelectedResource,
Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
ToolTip="{Binding Path=SelectedResource.DisplayName,
Mode=OneWay}"
Visibility="{Binding Path=ShowResourceList,
Converter={StaticResource boolToVisibility}}">
<inputToolkit:UxDropDown.ItemTemplate>
<DataTemplate>
<TextBlock AutomationProperties.AutomationId="SelectedResourceItemForTask"
Cursor="Hand"
Text="{Binding DisplayName}"
TextTrimming="CharacterEllipsis" />
</DataTemplate>
</inputToolkit:UxDropDown.ItemTemplate>
</inputToolkit:UxDropDown>
In this binding 'SelectedValue' is binded to 'SelectedResource' property in view model. In the property 'SelectedResource' we are firing property changed notification whenever it assumes a new value. Still not reflected in UI because of the root cause i just mentioned above. Any solution to this problem?