wpf - How to use Path, ElementName with markup extension
I am using this markup extension
<DataGridTextColumn Header="Something"
Binding="{controls:SwitchBinding Something, Yes, No}" />
It all works fine, except that now I need to specify Path and Element Name for the Binding.(maybe even 'mode')
I have unsuccessfully tried:
Binding="{controls:SwitchBinding {Binding Path=SelectedItem.SystemDefined, ElementName=dgrdStatementBlocks}, Yes, N开发者_如何学Pythono}"
Can somebody please point me to the correct way of doing this?
Thanks.
Why would you do this??
Binding="{controls:SwitchBinding {Binding Path=SelectedItem.SystemDefined, ElementName=dgrdStatementBlocks}, Yes, No}
Try the following:
Binding="{controls:SwitchBinding Path=SelectedItem.SystemDefined, ElementName=dgrdStatementBlocks, ValueIfTrue=Yes, ValueIfFalse=No}
Edit:
I tried this in a sample WPF(.Net4)
(not Silverlight
) application. And the following worked:
<CheckBox Name="CheckBox1"
IsChecked="True" />
<TextBlock Name="TextBlock1"
Text="{local:SwitchBinding ElementName=CheckBox1, Path=IsChecked, ValueIfTrue=Yes, ValueIfFalse=No}" />
精彩评论