Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>While H.B.'s answer will work, a more unobtrusive way to do this is through a new <a href="http://msdn.microsoft.com/en-us/library/ms749011.aspx" rel="nofollow">attached property</a>.</p> <p>Let's call it MoreCommand.</p> <p>You bind the Button to MoreCommand in the control template and bind MoreCommand to the command on the ViewModel at the point you declare the ComboBox instances.</p> <p>Details.</p> <p>1.) You create a static class that provides an attached property</p> <pre><code>public static class AttachedCommand { public static readonly DependencyProperty CommandProperty = DependencyProperty.RegisterAttached("Command", typeof(ICommand), typeof(AttachedCommand)); public static bool GetCommand(DependencyObject dependencyObject) { return (bool)dependencyObject.GetValue(CommandProperty); } public static void SetCommand(DependencyObject dependencyObject, bool value) { dependencyObject.SetValue(CommandProperty, value); } } </code></pre> <p>2.) You add support to your control template for this attached property</p> <pre><code> &lt;Popup x:Name="PART_Popup" IsOpen="{TemplateBinding IsDropDownOpen}"&gt; &lt;Border x:Name="PopupBorder" HorizontalAlignment="Stretch" Height="Auto" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Black" Background="White" CornerRadius="3"&gt; &lt;ScrollViewer x:Name="ScrollViewer" BorderThickness="0" Padding="1"&gt; &lt;StackPanel&gt; &lt;ItemsPresenter/&gt; &lt;Button Command={TemplateBinding local:AttachedCommand.Command}&gt;Other&lt;/Button&gt; &lt;/StackPanel&gt; &lt;/ScrollViewer&gt; &lt;/Border&gt; &lt;/Popup&gt; </code></pre> <p>Make sure that you define the "local" namespace.</p> <p>3.) In your view, you bind the attached property to you view model</p> <pre><code>&lt;ComboBox ItemsSource={Binding Items} local:AttachedCommand.Command={Binding FetchMoreItems} /&gt; </code></pre> <p>The advantage is that you don't need to subclass Combobox, and you could potentially combine multiple "customizations" of the same control in the future, without the risk of class explosion.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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