Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight - Determine visibility using multiple bindings
    primarykey
    data
    text
    <p>I currently have a simple class that holds various forms of data, I'll call it <code>MyData</code> for the purposes of this question. The class will usually be created in xaml under a container's resource section. It currently has a <code>DependencyProperty</code> named <code>Show</code> that signifies whether its data should be visible in the UI. A common use of this resource would be to template a <code>TextBlock</code> to show the data and bind <code>Show</code> to its <code>Visibility</code> using a converter. The value of <code>Show</code> itself usually comes from another <code>DependencyProperty</code> (typically in the ViewModel for MVVM implementations). I have an example shown below.</p> <pre><code>&lt;navigation:Page.Resources&gt; &lt;ViewModel x:Name="MyModel"/&gt; &lt;MyData Data="Some Sample Data" Show="{Binding ModelValue, ElementName=MyModel}"/&gt; &lt;DataTemplate&gt; &lt;TextBlock Text={Binding Data} Visibility="{Binding Show, Converter={StaticResource BoolToVisibilityConverter}}"/&gt; &lt;/DataTemplate&gt; &lt;/navigation:Page.Resources&gt; </code></pre> <p>The scenario above is obviously a simplified version of what I am currently working on, but it currently works perfectly. However, I need to allow multiple bindings to affect the data's visibility. To clarify, if and only if all values are true then the data should be shown. So, the MyData xaml from above would look more like this:</p> <pre><code>&lt;MyData Data="Some Sample Data"&gt; &lt;MyData.Show&gt; &lt;AnotherClass Value="{Binding ModelValue1, ElementName=MyModel}"/&gt; &lt;AnotherClass Value="{Binding ModelValue2, ElementName=MyModel}"/&gt; &lt;/MyData.Show&gt; &lt;/MyData&gt; </code></pre> <p>My first thought was to make <code>Show</code> an <code>ObservableCollection&lt;bool&gt;</code>, but it doesn't keep track of whether its items' values change, only if the items themselves change. When 'ModelValue1', for example, would change from true to false, the collection's <code>CollectionChanged</code> event would not be raised. So, I need a way to utilize multiple bindings to determine something's visibility.</p> <p>I realize this is a fairly long question, but its kind of a complicated one so I tried to be as detailed as needed. Please feel free to ask me to clarify anything.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload