Note that there are some explanatory texts on larger screens.

plurals
  1. POdatatrigger binding to viewmodel property
    primarykey
    data
    text
    <p>I'm trying to create a simple style data trigger that pulls it's binding value from a viewmodel property, as you can see below:</p> <pre><code> &lt;StackPanel Name="stackTextPanel" Orientation="Horizontal" Margin="0,8,0,0"&gt; &lt;StackPanel.Style&gt; &lt;Style TargetType="{x:Type StackPanel}"&gt; &lt;Style.Triggers&gt; &lt;DataTrigger Binding="{Binding QuickDrawBarPinned}" Value="False"&gt; &lt;Setter Property="Margin" Value="0,8,0,0" /&gt; &lt;/DataTrigger&gt; &lt;DataTrigger Binding="{Binding QuickDrawBarPinned}" Value="True"&gt; &lt;Setter Property="Margin" Value="0,48,0,0" /&gt; &lt;/DataTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/StackPanel.Style&gt; </code></pre> <p>I have also tried the variant</p> <pre><code>Binding="{Binding Path=QuickDrawBarPinned}" </code></pre> <p>but this is still not working when I press the button that changes the <strong>QuickDrawBarPinned</strong> property what am I doing wrong?</p> <p>I've implemented the property as so:</p> <pre><code> private bool _quickDrawBarPinned = false; /// &lt;summary&gt; /// Indicates if the Quick Draw Bar is pinned (stuck) or unpinned (retractable) /// &lt;/summary&gt; public bool QuickDrawBarPinned { get { return _quickDrawBarPinned; } set { _quickDrawBarPinned = value; OnPropertyChanged("QuickDrawBarPinned"); } } </code></pre> <p>This is the method that implements the change control</p> <pre><code> public virtual void OnPropertyChanged(string propertyInfo) { App.Current.Dispatcher.BeginInvoke((Action)(() =&gt; { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyInfo)); } } )); } </code></pre>
    singulars
    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