I have DataGrid Column Like this
<dxg:GridControl DockPanel.Dock="Right" Name="gridControl" ItemsSource="{Binding FilterWiseListOfWorkOrder,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" >
<dxg:GridColumn Header="Name" >
<dxg:GridColumn.DisplayMemberBinding>
<MultiBinding Converter="{StaticResource CellBackRoundColorOtTypeConvertor}" >
<Binding Path="RowData.Row" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}" />
<Binding Path="Listofcolor" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}" />
</MultiBinding>
</dxg:GridColumn.DisplayMemberBinding>
</dxg:GridColumn>
</dxg:GridControl>
Here <Binding Path="RowData.Row" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}" />
Row data is passed to convertor
But <Binding Path="Listofcolor" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}" />
Not able to pass the Listofcolor. this is not in the itemsource of Datagrid
. Listofcolor
is in Vm as a seperate list
Convertor
public class CellBackRoundColorOtTypeConvertor : MarkupExtension, IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{if (values[0] == DependencyProperty.UnsetValue || values[1] == DependencyProperty.UnsetValue)
// Here values[1] == DependencyProperty.UnsetValue is true
//Some Conversions
}
}
VM
public List<Ots> FilterWiseListOfWorkOrder
{
get { return filterWiseListOfWorkOrder; }
set
{
filterWiseListOfWorkOrder = value;
OnPropertyChanged(new PropertyChangedEventArgs("FilterWiseListOfWorkOrder"));
}
}
// This will fill in Ctor of Vm
public List<string> Listofcolor
{
get { return listofcolor; }
set { listofcolor = value; }
}
Q: How can pass this Listofcolor to converter?
Tried DataContext.Listofcolor
and tried using ElementName too
Update on Comment
如果您的VM是此usercontrol的datacontext,则通过DataContext访问Listofcolor。
<Binding Path="DataContext.Listofcolor" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}" />
<Binding Path="View.DataContext.Listofcolor"/>
这是我缺少的链接
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.