I have combo as
<ig:XamComboEditor Name="YComboEditor" ItemsSource="{Binding Path=YearsData}" DisplayMemberPath="SomeYear" SelectionChanged="YComboEditor_SelectionChanged" SelectedItem="{Binding SomeYear,Mode=TwoWay,Converter={StaticResource YearConverter}}">
</ig:XamComboEditor>
This is populated correctly
I have IvalueConverter which checkes for the year and then should return current year as selected
For some reason the IValueconverter is not triggered
Any ideas?
Hi,
assuming that this code is placed in some kind of an Initialization method this should set the selected value to the current year.
Regards
Right now the solution i have is
var collection = ComboEditor1.ItemsSource.Cast<YearData>().ToList(); var value = collection.Where(item => item.YearXX == DateTime.Today.Year).FirstOrDefault(); ComboEditor1.SelectedItem = value;
Is this correct approach?
could you provide simplified sample solution illustrating the issue you are experiencing ?
Right now I have the same approach as you mentioned
why do you need to set default selected value through a ValueConverter? Can't you set the current year to <SomeYear>property while creating your business object?
Hint that might be of help: when using SelectedItem property in binding you should ensure that SelectedItem's value can be found in XamComboEdiotr's ItemsSource. If you try to set SelectedItem to something that cannot be found in ItemsSource nothing will be selected