wpf - Data binding custom control with parent -


I have a UserControl that has listboxes.

On the original window, I have this user control and a button.

Ideally I want to use the ChangePropertyAction behavior on the parent button, and it lists the number of UserControl in the Countback

The idea is that if the user controls the list box If there is no entry in, the button is hidden on the parent window. Listback is bound to an observational label.

Can I make a dependency property to do this? I'm not sure how to calculate the listbox on this property. I

Thank you for any insights correctly in order to do this. ListBox

You can force access to ElementName From state button Then you want to use BooleanToVisibilityConverter to spell.

Do this:

  & lt; Window x: orbit = "NestedTreatWindow1" Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx / 2006 / xaml "title =" window1 "height =" 200 "width =" 300 "& gt; & Lt; Window.Resources & gt; & Lt; BooleanToVisibilityConverter x: key = "boolToVisibilityConverter" /> & Lt; /Window.Resources> & Lt; StackPanel & gt; & Lt; Button visibility = "{binding element name = myList, path = HasItems, converter = {StaticResource boolToVisibilityConverter}}" & gt; Text & lt; / Button & gt; & Lt; List box x: name = "myList" & gt; & Lt ;! - & lt; ListBoxItem & gt; Item A & lt; / ListBoxItem & gt; - & gt; & Lt; / ListBox & gt; & Lt; / StackPanel & gt; & Lt; / Window & gt;  

To make it work, ListBoxItems comment, or cancel comment ...


Comments

Popular posts from this blog

Is there an open source WebSockets (JavaScript) XMPP library? -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -

mysql - Can mysql_pconnect be called multiple times in one php page? -