Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>in my AttrubuteExpander User Control I have defined a dependency property as follow</p> <pre><code> public ICommand DeleteCommand { get { return (ICommand)GetValue(DeleteCommandProperty); } set { SetValue(DeleteCommandProperty, value); } } // Using a DependencyProperty as the backing store for DeleteCommandCommand. This enables animation, styling, binding, etc... public static readonly DependencyProperty DeleteCommandProperty = DependencyProperty.Register("DeleteCommand", typeof(ICommand), typeof(AttrubuteExpander ), new UIPropertyMetadata(null)); </code></pre> <p>I have binded the DeleteCommand Property to a button which is present in my user control as shown below</p> <pre><code> &lt;Button Width="20" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=my:AttributeExpander}, Path=DeleteCommand, Mode=OneWay}" &gt; &lt;/Button&gt; </code></pre> <p>Now in the container of my Collection i.e my ViewModel I have deifned a property of type ICommand as follow and binded the Command property and dependency property of user control together and it is working fine </p> <pre><code>public ICommand DeleteCommand { get { if (deleteCommand == null) { deleteCommand = new RelayCommand(x =&gt; Remove(null)); } return deleteCommand; } } </code></pre> <p>and the xaml is as follow</p> <pre><code>&lt;DataTemplate&gt; &lt;local:AttributeExpander DeleteConditionCommand="{Binding ElementName=lstExpander, Path=DataContext.DeleteCommand}"&gt;&lt;/local:AttributeExpander&gt; &lt;/DataTemplate&gt; </code></pre>
    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