开发者

WPF Binding: Expression evaluation

I have a listbox in markup and a detail control. The listbox template defines a details button for each element.开发者_高级运维 If this button is pressed a dependency property in the element's datasource is set to Visiblility == Visible. As long as I do have a selected item everything is OK. But if there is no selected item, the detail control is displayed always. Markup:

<Listbox x:Name="myListbox" />
<local:detailcontrol Visibility="{Binding ElementName=myListbox, Path=SelectedItem.DetailVisibility}" />

What I want is something like this:

<Listbox x:Name="myListbox" />
<local:detailcontrol Visibility="myListbox.SelectedItem != null ? {Binding ElementName=myListbox, Path=SelectedItem.DetailVisibility} : Visiblity.Hidden" />

Snippets both do not compile, but are provided to make my point clear.


Starting using the article at http://www.11011.net/wpf-binding-expressions I implemented something similar which solved my problem

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜