我在通过ElementName绑定的GridColumn.CellTemplate中有Hyperlink.Command。我想用RelativeSource做绑定,但是我不知道怎么做。在这方面的任何帮助都将不胜感激。谢谢……
<dxg:GridControl
DataContext="{StaticResource viewModel}"
Name="grid"
ItemsSource="{Binding Details}"
Grid.Row="1">
<dxg:GridControl.View>
<dxg:TableView
ShowGroupPanel="False" />
</dxg:GridControl.View>
<dxg:GridControl.Columns>
<dxg:GridColumn
Header="Even or Odd"
Width="200"
FieldName="EvenOrOdd">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<TextBlock
Padding="4,0">
<Hyperlink
Command="{Binding DataContext.ToggleCommand, ElementName=grid}"
CommandParameter="{Binding RowData.Row}">
<TextBlock
Text="{Binding Value}" />
</Hyperlink>
</TextBlock>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn
FieldName="Number"
Width="200" />
</dxg:GridControl.Columns>
</dxg:GridControl>发布于 2012-05-07 02:20:08
您必须指定AncestorType
Command="{Binding DataContext.ToggleCommand,
RelativeSource={RelativeSource AncestorType=dxg:GridControl}}"https://stackoverflow.com/questions/10472975
复制相似问题