I am trying to get the sort working correctly on this field in a xamdatapresenter. The ascending sort seems to work fine (1, 2, 3 ,4 ,5 ,6,7,8,910,11,12,13,14,15,16) but when i click the arrow for descending, the order is incorrect. It is (16,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15). ?? Um, why does 16 come before everything else here? Also, is there an easy way to sort alphabetically vs numerically etc?
<igDP:UnboundField x:Name="Index" Label="#" Column="0" RowSpan="2" Converter="{StaticResource ValueConverter}"> <igDP:UnboundField.Settings> <igDP:FieldSettings CellMinWidth="30" CellMaxWidth="30"> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <TextBlock Text="{Binding Path=DataItemIndex, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource IndexConverter}}" VerticalAlignment="Center"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.CellValuePresenterStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField>______________________________________________________i coudn't see most of the code when i viewed this, so here it is again below<igDP:UnboundField x:Name="Index" Label="#" Column="0" RowSpan="2" Converter="{StaticResource ValueConverter}"><igDP:UnboundField.Settings><igDP:FieldSettings ><igDP:FieldSettings.CellValuePresenterStyle><Style TargetType="{x:Type igDP:CellValuePresenter}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"><TextBlock Text="{Binding Path=DataItemIndex, UpdateSourceTrigger=PropertyChanged,Converter={StaticResource IndexConverter}}"/></ControlTemplate></Setter.Value></Setter></Style></igDP:FieldSettings.CellValuePresenterStyle></igDP:UnboundField.Settings></igDP:UnboundField>oh i included the indexconverter and valueconverters as well
Hello,
I have created a sample project for you using the code I have posted before. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
can you supply a very simple sample project that does this correctly?
I tried your code and it doesn't work correctly either, I get out of order and missing in "Index #'s. However; I was unaware that there was additional code in the code-behind that is doing somethign also.
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
Thank you for your post. I have been looking into it and the code you have provided and I suggest you use the following code for the UnboundField instead of yours:
<igDP:UnboundField x:Name="Index" Label="#" BindingPath="Index" > <igDP:UnboundField.Settings> <igDP:FieldSettings CellMinWidth="30" CellMaxWidth="30"> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate > <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=Value, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource IndexConverter}}" VerticalAlignment="Center"/> </DataTemplate> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.CellValuePresenterStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField>
And this one instead of yours for the Convert method of the IndexConverter Converter:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { int intValue; if (value != null ) { if (value.ToString() == "Text") { return Binding.DoNothing; } bool isInt = int.TryParse(value.ToString(), out intValue); if (isInt) { if (intValue == -1) { return null; } } return (int)value + 1; } return Binding.DoNothing; }
Please let me know if this helps you or you need further clarifications on this matter.