123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <ContextMenu x:Class="CustomControls.ContextMenuStrip" Style="{DynamicResource ContextMenuStyle1}"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:s="clr-namespace:System;assembly=mscorlib"
- xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
- xmlns:local="clr-namespace:CustomControls">
- <ContextMenu.Resources>
- <SolidColorBrush x:Key="Menu.Static.Border" Color="Gray"/>
- <SolidColorBrush x:Key="Menu.Static.Background" Color="White"/>
- <SolidColorBrush x:Key="Menu.Margin.Background" Color="#FFF1F1F1"/>
- <SolidColorBrush x:Key="Menu.QAT.Background" Color="Transparent"/>
- <Style x:Key="ContextMenuStyle1" TargetType="{x:Type ContextMenu}">
- <Setter Property="VerticalOffset" Value="-1"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ContextMenu}" >
- <mwt:SystemDropShadowChrome Color="#00FFFFFF" Name="Shdw" SnapsToDevicePixels="True">
- <StackPanel Orientation="Vertical">
- <Border x:Name="ToolBarBorder" Background="{DynamicResource Menu.Static.Background}" BorderThickness="1" Margin="0,0,0,1" BorderBrush="Transparent" Visibility="Collapsed">
- <local:ToolStrip x:Name="ToolBar" Height="26" GripVisible="False" Background="{DynamicResource Menu.QAT.Background}"/>
- </Border>
- <Border Background="{DynamicResource Menu.Static.Background}" BorderThickness="{TemplateBinding Border.BorderThickness}" BorderBrush="{DynamicResource Menu.Static.Border}" Name="ContextMenuBorder">
- <ScrollViewer Style="{DynamicResource {ComponentResourceKey TypeInTargetAssembly=FrameworkElement, ResourceId=MenuScrollViewer}}" Name="ContextMenuScrollViewer" Margin="1,0,1,0" Grid.ColumnSpan="2">
- <Grid>
- <Canvas Width="0" Height="0" HorizontalAlignment="Left" VerticalAlignment="Top">
- <Rectangle Fill="{x:Null}" Name="OpaqueRect" Width="Auto" Height="Auto" />
- </Canvas>
- <Rectangle Fill="{DynamicResource Menu.Margin.Background}" Width="24" HorizontalAlignment="Left" />
- <ItemsPresenter Name="ItemsPresenter" Margin="0,1,0,1" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" KeyboardNavigation.DirectionalNavigation="Cycle" />
- </Grid>
- </ScrollViewer>
- </Border>
- </StackPanel>
- </mwt:SystemDropShadowChrome>
- <ControlTemplate.Triggers>
- <Trigger Property="ContextMenuService.HasDropShadow">
- <Setter Property="FrameworkElement.Margin" TargetName="Shdw">
- <Setter.Value>
- <Thickness>0,0,5,5</Thickness>
- </Setter.Value>
- </Setter>
- <Setter Property="mwt:SystemDropShadowChrome.Color" TargetName="Shdw">
- <Setter.Value>
- <Color>#71000000</Color>
- </Setter.Value>
- </Setter>
- <Trigger.Value>
- <s:Boolean>True</s:Boolean>
- </Trigger.Value>
- </Trigger>
- <Trigger Property="ScrollViewer.CanContentScroll" SourceName="ContextMenuScrollViewer">
- <Setter Property="Canvas.Top" TargetName="OpaqueRect">
- <Setter.Value>
- <Binding Path="VerticalOffset" ElementName="ContextMenuScrollViewer" />
- </Setter.Value>
- </Setter>
- <Setter Property="Canvas.Left" TargetName="OpaqueRect">
- <Setter.Value>
- <Binding Path="HorizontalOffset" ElementName="ContextMenuScrollViewer" />
- </Setter.Value>
- </Setter>
- <Trigger.Value>
- <s:Boolean>False</s:Boolean>
- </Trigger.Value>
- </Trigger>
- <Trigger Property="HasItems" SourceName="ToolBar" Value="True">
- <Setter Property="Visibility" TargetName="ToolBarBorder" Value="Visible"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </ContextMenu.Resources>
- </ContextMenu>
|