Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

ContextMenu template autosize problam on visibility item?

$
0
0

hi,

this is my xaml code:

<Style TargetType="ContextMenu" x:Key="ContextMenuStyle"><Setter Property="Grid.IsSharedSizeScope" Value="true"/><Setter Property="HasDropShadow" Value="True"/><Setter Property="Background" Value="{StaticResource ControlBackground}"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="ContextMenu"><Border 
          Name="Border" Background="{TemplateBinding Background}"  BorderBrush="{StaticResource BorderForeground}"
          BorderThickness="1" ><StackPanel IsItemsHost="True"
                      KeyboardNavigation.DirectionalNavigation="Cycle"/></Border><ControlTemplate.Triggers><Trigger Property="HasDropShadow" Value="true"><Setter TargetName="Border" Property="Padding" Value="0"/><Setter TargetName="Border" Property="CornerRadius" Value="0"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style><Style TargetType="ContextMenu" x:Key="treeItemContextMenuStyle" BasedOn="{StaticResource ContextMenuStyle}"/><Style TargetType="{x:Type MenuItem}" x:Key="ContextMenuItemStyle"><Setter Property="Padding" Value="0,0,30,0"/><Setter Property="Foreground" Value="{StaticResource TextForeground_Normal}"/><Setter Property="Background" Value="{StaticResource ControlBackground}"/><Setter Property="Height" Value="30"/><Setter Property="Cursor" Value="Hand"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type MenuItem}"><Border Cursor="{TemplateBinding Cursor}"
           x:Name="Border"
           Background="{TemplateBinding Background}"><ContentPresenter
             Margin="{TemplateBinding Padding}"
             RecognizesAccessKey="True" ><ContentPresenter.Content><StackPanel Orientation="Horizontal" Margin="2"><Viewbox><Label Padding="0" Style="{TemplateBinding Tag}"/></Viewbox><Label Margin="2,0,0,0" Content="{TemplateBinding Header}" Foreground="{TemplateBinding Foreground}"/></StackPanel></ContentPresenter.Content></ContentPresenter></Border><ControlTemplate.Triggers><Trigger Property="IsKeyboardFocused" Value="true"><Setter TargetName="Border" Property="BorderBrush" Value="#FFB7BDCB" /></Trigger><Trigger Property="IsMouseOver" Value="true"><Setter TargetName="Border" Property="Background" Value="#FFECF0F9" /><Setter Property="Foreground" Value="{StaticResource ControlEforeground_MouseOver}" /></Trigger><Trigger Property="IsPressed" Value="true"><Setter TargetName="Border" Property="Background" Value="#FFB7BDCB" /><Setter TargetName="Border" Property="BorderBrush" Value="#FF646464" /></Trigger><Trigger Property="IsEnabled" Value="false"><Setter TargetName="Border" Property="Background" Value="#EEEEEE" /><Setter TargetName="Border" Property="BorderBrush" Value="#AAAAAA" /><Setter Property="Foreground" Value="#888888"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style>

boot i change items visibility no autosized contextmenu.

example image:



Viewing all articles
Browse latest Browse all 18858

Trending Articles