Pergunta

I'm recently working on a WPF application that uses the datagrid from the WPF toolkit (and extended toolkit)

I'm using a datagridtemplatecolumn because I show a tooltip on some of the values for some users. Other columns are datagridtextcolumns.

I can sort on the status by adding the sortmemberpath on status, but status is a number (1,2,3,4,5..) and I convert those numbers to the names of another column. If I sort by this sortmemberpath, I first get the 1 then, 2, then 3, etc. but I want to sort alphabetical on the converted values.

<Toolkit:DataGridTemplateColumn x:Name="dgtcStatus" Header="Status" SortMemberPath="Status_W52" Width="*">
  <Toolkit:DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
      <TextBlock x:Name="Status" Text="{Binding Path=Status_W52, Converter={StaticResource StatusConverter}}">
        <TextBlock.ToolTip>
          <ToolTip Visibility="{Binding Path=Status_W52, Converter={StaticResource VisibilityConverter}}">
            <TextBlock Text="{Binding Path=Discription_W52, Converter={StaticResource DiscriptionConverter}}"/>
          </ToolTip>
        </TextBlock.ToolTip>
      </TextBlock>
    </DataTemplate>
  </Toolkit:DataGridTemplateColumn.CellTemplate>
</Toolkit:DataGridTemplateColumn>

Anyone has an idea?

Foi útil?

Solução

Can you promote the Status_W52 from an int to a more complex type?

public Status_W52
{
   int NumericValue {get;set;}
   string Name {get;set;}
}

your Converter will take the full instance of Status_W52, parse through "NumericValue", return your int for sort, but also could update the "Name" property of the passed ref, on which you can later sort..

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top