I use a multibinding with a value converter to provide the visual display of a collection of items in my DataContext
. Here is a snippet of the XAML;
<DataGrid.Columns> <DataGridTextColumn x:Name="Column1" SortMemberPath="{Binding Path=SomeDataModelProperty}"> <DataGridTextColumn.Binding> <MultiBinding Converter="{StaticResource MyCustomConverter}"> <Binding Path="SomeDataModelProperty" /> <Binding RelativeSource="{RelativeSource Self}" Path="ActualWidth" /> <!-- Other bindings --> </MultiBinding> </DataGridTextColumn.Binding> </DataGridTextColumn>
The binding on the SortMemberPath
is such that I can sort by the property in my DataContext
. However, I get an error on the output window
Cannot find governing FrameworkElement or FrameworkContentElement for target element.
Googling this issue yields a result using DXGrid by DevExpress, but not one using the standard WPF data grid. Does anyone know the correct way to provide the sorting to the data grid column?