Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <ResourceDictionary
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:local="clr-namespace:TestToolBarTemplateProject.resources"
- >
- <!-- DONE: ToolBar Grip (ToolBarThumb) Template -->
- <ControlTemplate x:Key="UniformGridToolBarThumb"
- TargetType="{x:Type Thumb}"
- >
- <Border
- SnapsToDevicePixels="True"
- >
- <Rectangle
- Margin="3,2"
- MinHeight="4"
- MinWidth="4"
- >
- <Rectangle.Fill>
- <DrawingBrush
- TileMode="Tile"
- Viewbox="0,0,8,8"
- ViewboxUnits="Absolute"
- Viewport="0,0,4,4"
- ViewportUnits="Absolute"
- >
- <DrawingBrush.Drawing>
- <DrawingGroup>
- <GeometryDrawing
- Brush="{StaticResource
- {x:Static SystemColors.ControlDarkDarkBrushKey}
- }"
- Geometry="M 4 4 L 4 8 L 8 8 L 8 4 z"
- />
- </DrawingGroup>
- </DrawingBrush.Drawing>
- </DrawingBrush>
- </Rectangle.Fill>
- </Rectangle>
- </Border>
- </ControlTemplate>
- <!-- FIXME: OverflowPanel not working -->
- <ControlTemplate x:Key="UniformGridToolBarOverflowButtonTemplate"
- TargetType="{x:Type ToggleButton}"
- >
- <Border x:Name="Border"
- Background="{Binding
- Path=Background,
- RelativeSource={
- RelativeSource FindAncestor,
- AncestorType=ToolBar
- }
- }"
- HorizontalAlignment="Right"
- SnapsToDevicePixels="true"
- >
- <Grid>
- <Path x:Name="Arrow"
- Data="M -0.5 3 L 5.5 3 L 2.5 6 Z"
- Fill="{StaticResource {x:Static
- SystemColors.ControlTextBrushKey
- }}"
- Margin="2,3"
- VerticalAlignment="Bottom"
- />
- <ContentPresenter />
- </Grid>
- </Border>
- <ControlTemplate.Triggers>
- <DataTrigger
- Binding="{Binding
- Path=Orientation,
- RelativeSource={RelativeSource TemplatedParent}
- }"
- Value="Vertical"
- >
- <Setter TargetName="Arrow"
- Property="Data"
- Value="M 3 -0.5 L 3 5.5 L 6 2.5 Z"
- />
- </DataTrigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- <!-- FIXME: OverflowPanel not working, UniformGrid.Columns|Rows not working -->
- <ControlTemplate x:Key="UniformGridToolBar"
- TargetType="ToolBar"
- >
- <Border x:Name="Border"
- Background="{Binding
- Path=Background,
- RelativeSource={RelativeSource TemplatedParent}
- }"
- BorderBrush="{Binding
- Path=Border,
- RelativeSource={RelativeSource TemplatedParent}
- }"
- BorderThickness="1"
- CornerRadius="2"
- >
- <DockPanel>
- <Thumb x:Name="ToolBarThumb"
- DockPanel.Dock="Left"
- Cursor="SizeAll"
- Template="{StaticResource UniformGridToolBarThumb}"
- />
- <ToggleButton x:Name="OverflowButton"
- DockPanel.Dock="Right"
- ClickMode="Press"
- IsChecked="{Binding
- IsOverflowOpen,
- Mode=TwoWay,
- RelativeSource={RelativeSource TemplatedParent}
- }"
- IsEnabled="{TemplateBinding HasOverflowItems}"
- Template="{StaticResource
- UniformGridToolBarOverflowButtonTemplate
- }"
- >
- <Popup x:Name="OverflowPopup"
- AllowsTransparency="true"
- Focusable="false"
- IsOpen="{Binding
- IsOverflowOpen,
- RelativeSource={RelativeSource TemplatedParent}
- }"
- Placement="Bottom"
- PopupAnimation="Slide"
- StaysOpen="false"
- >
- <Border x:Name="DropDownBorder"
- Background="{Binding
- Path=Background,
- RelativeSource={RelativeSource TemplatedParent}
- }"
- BorderBrush="{Binding
- Path=Border,
- RelativeSource={RelativeSource TemplatedParent}
- }"
- BorderThickness="1"
- >
- <!--<StackPanel x:Name="PART_ToolBarOverflowPanel"
- Focusable="true"
- FocusVisualStyle="{x:Null}"
- KeyboardNavigation.TabNavigation="Cycle"
- KeyboardNavigation.DirectionalNavigation="Cycle"
- Margin="2"
- />-->
- <ToolBarOverflowPanel
- x:Name="PART_ToolBarOverflowPanel"
- Focusable="true"
- FocusVisualStyle="{x:Null}"
- KeyboardNavigation.TabNavigation="Cycle"
- KeyboardNavigation.DirectionalNavigation="Cycle"
- Margin="2"
- WrapWidth="200"
- />
- </Border>
- </Popup>
- </ToggleButton>
- <!--<ToolBarPanel x:Name="PART_ToolBarPanel"
- IsItemsHost="True"
- Visibility="Collapsed"
- />
- <ItemsControl
- ItemsSource="{Binding StaticResource PART_ToolBarPanel.Panel}"
- >
- <ItemsControl.ItemsPanel>
- <ItemsPanelTemplate>-->
- <UniformGrid
- ClipToBounds="True"
- Columns="{Binding
- Path=local:UniformGridToolBarAttachedProperties.ItemColumns,
- RelativeSource={RelativeSource TemplatedParent}
- }"
- Rows="{Binding
- Path=local:UniformGridToolBarAttachedProperties.ItemRows,
- RelativeSource={RelativeSource TemplatedParent}
- }"
- IsItemsHost="True"
- Margin="0,1,2,2"
- />
- <!--</ItemsPanelTemplate>
- </ItemsControl.ItemsPanel>
- </ItemsControl>-->
- </DockPanel>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsOverflowOpen" Value="true">
- <Setter TargetName="ToolBarThumb"
- Property="IsEnabled"
- Value="false"
- />
- </Trigger>
- <Trigger Property="ToolBarTray.IsLocked" Value="true">
- <Setter TargetName="ToolBarThumb"
- Property="Visibility"
- Value="Collapsed"
- />
- </Trigger>
- <Trigger Property="Orientation" Value="Vertical">
- <Setter TargetName="ToolBarThumb"
- Property="DockPanel.Dock"
- Value="Top"
- />
- </Trigger>
- <Trigger Property="Orientation" Value="Vertical">
- <Setter TargetName="OverflowButton"
- Property="DockPanel.Dock"
- Value="Bottom"
- />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </ResourceDictionary>
Advertisement
Add Comment
Please, Sign In to add comment