开发者

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}" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜