Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Normally the property IsDropDown effects the popup,i edited the combobox template so the popup and the togglebutton who controls it- would be bined to other property -Tag </p> <pre><code> &lt;Style x:Key="ComboBoxStyle1" TargetType="{x:Type ComboBox}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type ComboBox}"&gt; &lt;Grid x:Name="MainGrid" SnapsToDevicePixels="true"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Popup x:Name="PART_Popup" StaysOpen="True" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom"&gt; &lt;Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=MainGrid}"&gt; &lt;Border x:Name="DropDownBorder" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"&gt; &lt;ScrollViewer x:Name="DropDownScrollViewer"&gt; &lt;Grid RenderOptions.ClearTypeHint="Enabled"&gt; &lt;Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0"&gt; &lt;Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=DropDownBorder}" Height="{Binding ActualHeight, ElementName=DropDownBorder}" Width="{Binding ActualWidth, ElementName=DropDownBorder}"/&gt; &lt;/Canvas&gt; &lt;ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/&gt; &lt;/Grid&gt; &lt;/ScrollViewer&gt; &lt;/Border&gt; &lt;/Microsoft_Windows_Themes:SystemDropShadowChrome&gt; &lt;/Popup&gt; &lt;ToggleButton BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" IsChecked="{Binding Tag, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxReadonlyToggleButton}"/&gt; &lt;ContentPresenter ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Content="{TemplateBinding SelectionBoxItem}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/&gt; &lt;/Grid&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true"&gt; &lt;Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/&gt; &lt;Setter Property="Color" TargetName="Shdw" Value="#71000000"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="HasItems" Value="false"&gt; &lt;Setter Property="Height" TargetName="DropDownBorder" Value="95"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsEnabled" Value="false"&gt; &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/&gt; &lt;Setter Property="Background" Value="#FFF4F4F4"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsGrouping" Value="true"&gt; &lt;Setter Property="ScrollViewer.CanContentScroll" Value="false"/&gt; &lt;/Trigger&gt; &lt;Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false"&gt; &lt;Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/&gt; &lt;Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>then if you want to open\close the combobox you just need to set his Tag property to True\False :</p> <pre><code>&lt;ComboBox Style="{DynamicResource ComboBoxStyle1}" Tag="True"/&gt; </code></pre>
 

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