您可以在 Unified Service Desk 中設定工具列,以便在現有工具列中創建或管理按鈕,或者完全創建新工具列。 有關工具列的概述,請參閱 Unified Service Desk 中的工具列。
創建工具列
在創建工具列之前,請確保已配置工具列容器托管控件。 有關更多資訊,請參閱工具列容器(托管控件)。
登入 Unified Service Desk 管理介面。
選擇 Basic Settings 下的 Toolbars。
選擇 + 新增。
在新增工具列頁面上。
鍵入新工具列的名稱。
鍵入工具列的標題,該標題顯示在工具列條的左邊緣。
選擇 Save 以啟用 Buttons 區域。
在 Buttons 區域下,選擇 + New Toolbar Button 以創建一個要放置在工具列上的按鈕。
在 New Toolbar Button 頁面上:
指定按鈕的名稱。
指定工具列按鈕的影像檔的名稱。
在 ButtonText 字段中,鍵入按鈕的標籤。
要控制按鈕在工具列上的從左到右顯示順序,請在 Order 欄位中指定一個整數值。 按鈕按升序從左到右排列。
選擇 Save 以啟用 Actions 區域。
在 Actions 區域下,選擇 添加現有動作呼叫 來為按鈕添加動作呼叫。 此時將顯示 Lookup Records (查找記錄) 窗格。
在Actions區域下的搜尋框中,鍵入要附加到按鈕的動作呼叫名稱。 從清單中選擇動作呼叫,然後選擇 添加。
如果您想將按鈕附加到新的操作呼叫,請選擇New(新建),然後創建一個操作呼叫並將其添加到UII操作中。 有關更多資訊,請參閱 為 UII 動作建立動作呼叫。
至於工具列上的額外按鈕,請按照步驟 5-8 進行。
在工具列中添加按鈕和動作調用後,將工具列附加到工具列容器。 這樣做的目的是為了在 Unified Service Desk 的桌面上指定新工具列的位置。 打開工具列定義后,選擇 相關 選項卡,然後選擇 托管控件。
在下一頁上,選擇 Add Existing Hosted Control (添加現有托管控件)。 此時將顯示 Lookup Records (查找記錄) 窗格。
在搜索框中,鍵入工具列容器托管控件的名稱,選擇 搜索,然後從清單中選擇托管控件,然後選擇 添加。
選取 [儲存]。
在 Styles (樣式 ) 區域的 Custom Styles (自定義樣式 ) 文字框中,編寫 XAML 字串以自訂工具列和按鈕。 詳細資訊: 工具列中的樣式
選取 [儲存]。
從現有工具列添加/刪除按鈕
登入 Unified Service Desk 管理介面。
選擇 Basic Settings 下的 Toolbars。
在 toolbars (工具列) 頁面上,選擇要修改的工具列的名稱。
下一頁顯示工具列定義。
使用 Buttons 區域添加更多按鈕。 有關更多資訊,請參閱上一節中的步驟 6-10。
通過在 Buttons 下選擇按鈕名稱來修改現有按鈕。 這將打開按鈕定義頁面,您可以在其中更改有關按鈕的資訊,例如名稱、按鈕文本(標籤)、順序和作調用。
選擇 Save 以儲存變更。
工具列中的樣式
您現在可以使用工具列設定視窗中的自訂樣式欄位自訂 Unified Service Desk 中的工具列。 “自定義樣式”字段支援定義 ResourceDictionaryStyle 和 Brush 資源的可擴展應用程式標記語言 (XAML)。
字典中的資源是指 Unified Service Desk 用戶端應用程式上可用的其他資源。 載入和解析 XAML 字串是在執行時進行的,以創建 ResourceDictionary 並將工具列控制項的資源與 ResourceDictionary 合併。 此外,工具列 ResourceDictionary 內可以具有按鈕類型的樣式。 使用這些樣式,您可以自訂工具列和按鈕。
範例 1:定義 Style 和 Brush 資源之 ResourceDictionary 的範例 XAML 示範如何自訂關於工具列。
備註
您可以在 Unified Service Desk - 統一介面示例包中找到此示例 XAML 樣式。
<ResourceDictionary xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
xmlns:usd="clr-namespace:Microsoft.Crm.UnifiedServiceDesk.Dynamics;assembly=Microsoft.Crm.UnifiedServiceDesk.Dynamics"
xmlns:controlStyles="clr-namespace:Microsoft.Crm.UnifiedServiceDesk.Dynamics.Controls.Styles;assembly=Microsoft.Crm.UnifiedServiceDesk.Dynamics"
xmlns:usdPanelLayouts="clr-namespace:Microsoft.Crm.UnifiedServiceDesk.Dynamics.PanelLayouts;assembly=Microsoft.Crm.UnifiedServiceDesk.Dynamics"
xmlns:themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna"
xmlns:control="clr-namespace:Microsoft.Crm.UnifiedServiceDesk.Dynamics.Controls;assembly=Microsoft.Crm.UnifiedServiceDesk.Dynamics">
<Style x:Key="ToolBarMainPanelBorderStyle" TargetType="{x:Type Border}">
<Setter Property="Margin" Value="0,0,0,0"/>
<Setter Property="CornerRadius" Value="3,3,3,3"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
<Setter Property="CornerRadius" Value="0,0,0,0"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="ToolBarThumbStyle" TargetType="{x:Type Thumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border Background="Transparent" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
<Rectangle>
<Rectangle.Fill>
<DrawingBrush TileMode="Tile" Viewbox="0,0,4,4" Viewport="0,0,4,4" ViewportUnits="Absolute" ViewboxUnits="Absolute">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="White" Geometry="M 1 1 L 1 3 L 3 3 L 3 1 z"/>
<GeometryDrawing Brush="{DynamicResource ToolBarGripper}" Geometry="M 0 0 L 0 2 L 2 2 L 2 0 z"/>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Cursor" Value="SizeAll"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ToolBarHorizontalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="MinHeight" Value="0"/>
<Setter Property="MinWidth" Value="0"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="Bd" Background="Transparent" CornerRadius="0" SnapsToDevicePixels="true">
<Image Source="{DynamicResource ImageMoreToolBarButtons}" Margin="7,5,7,5" Width="16" Height="16" VerticalAlignment="Bottom" HorizontalAlignment="Right"
AutomationProperties.Name="More Menu"></Image>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource USDTabBackgroundBrush}"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource USDTabBackgroundBrush}"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource ToolBarGripper}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
<Setter Property="Background" Value="Transparent"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="MainToolBarFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle SnapsToDevicePixels="true" Stroke="White"
StrokeDashArray="1 2" StrokeThickness="1"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ToolBarVerticalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
<Setter Property="MinHeight" Value="0"/>
<Setter Property="MinWidth" Value="0"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Continue"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="Bd" Background="Transparent" CornerRadius="0" SnapsToDevicePixels="true">
<Image Source="{DynamicResource ImageMoreToolBarButtons}" Margin="7,5,7,5" Width="16" Height="16" VerticalAlignment="Bottom" HorizontalAlignment="Right"
AutomationProperties.Name="More Menu"></Image>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource USDTabBackgroundBrush}"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource USDTabBackgroundBrush}"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource ToolBarGripper}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
<Setter Property="Background" Value="Transparent"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type ToolBar}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Local"/>
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Continue"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToolBar}">
<Grid x:Name="Grid" Margin="0,0,0,0" SnapsToDevicePixels="true" Height="42">
<Grid x:Name="OverflowGrid" HorizontalAlignment="Right" Margin="0,0,-11,0">
<ToggleButton x:Name="OverflowButton" ClickMode="Press" FocusVisualStyle="{x:Null}" IsChecked="{Binding IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
IsEnabled="{TemplateBinding HasOverflowItems}" Style="{StaticResource ToolBarHorizontalOverflowButtonStyle}" Visibility="Collapsed"
Margin="0,0,0,5">
</ToggleButton>
<Popup x:Name="OverflowPopup" AllowsTransparency="true" Focusable="True" IsOpen="{Binding IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom" StaysOpen="false">
<themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">
<Border x:Name="ToolBarSubMenuBorder" BorderBrush="{DynamicResource ToolBarMenuBorder}" BorderThickness="1" Background="{DynamicResource ToolBarSubMenuBackground}" RenderOptions.ClearTypeHint="Enabled">
<ToolBarOverflowPanel x:Name="PART_ToolBarOverflowPanel" KeyboardNavigation.DirectionalNavigation="Continue" FocusVisualStyle="{x:Null}" Focusable="true" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.TabNavigation="Cycle" WrapWidth="200"/>
</Border>
</themes:SystemDropShadowChrome>
</Popup>
</Grid>
<Border x:Name="MainPanelBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" Style="{StaticResource ToolBarMainPanelBorderStyle}">
<DockPanel KeyboardNavigation.TabIndex="1" KeyboardNavigation.TabNavigation="Local">
<Thumb x:Name="ToolBarThumb" Margin="-3,-1,0,0" Padding="6,5,1,6" Style="{StaticResource ToolBarThumbStyle}"/>
<ContentPresenter x:Name="ToolBarHeader" ContentSource="Header" HorizontalAlignment="Center" Margin="4,0,4,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
<ToolBarPanel x:Name="PART_ToolBarPanel" IsItemsHost="true" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</DockPanel>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasOverflowItems" Value="true">
<Setter Property="Visibility" TargetName="OverflowButton" Value="Visible"/>
</Trigger>
<Trigger Property="IsOverflowOpen" Value="true">
<Setter Property="IsEnabled" TargetName="ToolBarThumb" Value="false"/>
</Trigger>
<Trigger Property="Header" Value="{x:Null}">
<Setter Property="Visibility" TargetName="ToolBarHeader" Value="Collapsed"/>
</Trigger>
<Trigger Property="ToolBarTray.IsLocked" Value="true">
<Setter Property="Visibility" TargetName="ToolBarThumb" Value="Collapsed"/>
</Trigger>
<Trigger Property="HasDropShadow" SourceName="OverflowPopup" Value="true">
<Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
<Setter Property="SnapsToDevicePixels" TargetName="Shdw" Value="true"/>
<Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
</Trigger>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Margin" TargetName="Grid" Value="1,3,1,1"/>
<Setter Property="Style" TargetName="OverflowButton" Value="{StaticResource ToolBarVerticalOverflowButtonStyle}"/>
<Setter Property="Height" TargetName="ToolBarThumb" Value="10"/>
<Setter Property="Width" TargetName="ToolBarThumb" Value="Auto"/>
<Setter Property="Margin" TargetName="ToolBarThumb" Value="-1,-3,0,0"/>
<Setter Property="Padding" TargetName="ToolBarThumb" Value="5,6,6,1"/>
<Setter Property="Margin" TargetName="ToolBarHeader" Value="0,0,0,4"/>
<Setter Property="Margin" TargetName="PART_ToolBarPanel" Value="1,0,2,2"/>
<Setter Property="DockPanel.Dock" TargetName="ToolBarThumb" Value="Top"/>
<Setter Property="DockPanel.Dock" TargetName="ToolBarHeader" Value="Top"/>
<Setter Property="HorizontalAlignment" TargetName="OverflowGrid" Value="Stretch"/>
<Setter Property="VerticalAlignment" TargetName="OverflowGrid" Value="Bottom"/>
<Setter Property="Placement" TargetName="OverflowPopup" Value="Right"/>
<Setter Property="Margin" TargetName="MainPanelBorder" Value="0,0,0,11"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Local"/>
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Continue"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
<Setter Property="Background" Value="Transparent"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="ToolBarButtonBaseStyle">
<Setter Property="Control.BorderThickness" Value="0"/>
<Setter Property="Control.Padding" Value="0"/>
<Setter Property="Control.Background" Value="Transparent"/>
<Setter Property="Control.BorderBrush" Value="Transparent"/>
<Setter Property="Control.Foreground" Value="{DynamicResource ToolBarFontColor}"/>
<Setter Property="Control.FontFamily" Value="Segoe UI"/>
<Setter Property="Control.FontSize" Value="12"/>
</Style>
<Style x:Key="ToolbarButtonTemplate" TargetType="{x:Type control:ToolbarButton}" BasedOn="{StaticResource ToolBarButtonBaseStyle}">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontFamily" Value="Segoe UI"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FocusVisualStyle" Value="{DynamicResource MainToolBarFocusVisual}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type control:ToolbarButton}">
<Border x:Name="Bd" Height="42" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
<StackPanel x:Name="AboutToolBarButtonStackPanel" Orientation="Horizontal" Margin="7,0,7,0">
<Image Margin="0,0,7,0" x:Name="Icon" VerticalAlignment="Center" MaxWidth="16" MaxHeight="16" Source="{TemplateBinding Image}"/>
<ContentPresenter Margin="0,7,0,7" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Text" Value="{x:Null}">
<Setter TargetName="Icon" Property="Margin" Value="0,0,0,0"/>
<Setter TargetName="AboutToolBarButtonStackPanel" Property="Margin" Value="13,0,13,0"/>
</Trigger>
<Trigger Property="Image" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ToolBarButtonHover}"/>
<Setter Property="Foreground" Value="{DynamicResource ToolBarTextFontHighlightColor}"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ToolBarButtonHover}"/>
<Setter Property="Foreground" Value="{DynamicResource ToolBarTextFontHighlightColor}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ToolBarSplitButtonStyle" TargetType="{x:Type control:SplitButton}" BasedOn="{StaticResource ToolBarButtonBaseStyle}" >
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Height" Value="42"/>
<Setter Property="FocusVisualStyle" Value="{DynamicResource MainToolBarFocusVisual}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type control:SplitButton}">
<Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<StackPanel Orientation="Horizontal" Margin="0,0,0,0">
<Button x:Name="PART_Button" Margin="0,0,0,0" Style="{DynamicResource ButtonStyle}" AutomationProperties.Name="{Binding Path=(AutomationProperties.Name), RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type control:SplitButton}}}" FocusVisualStyle="{DynamicResource MainToolBarFocusVisual}" >
<StackPanel Orientation="Horizontal">
<Image x:Name="Icon" Margin="7,0,7,0" VerticalAlignment="Center" MaxWidth="16" MaxHeight="16" Source="{TemplateBinding Image}"/>
<ContentPresenter x:Name="ToolBarSplitButtonContent" Margin="0,7,7,7" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</StackPanel>
</Button>
<Separator Style="{DynamicResource VerticalSeparatorStyle}" Height="1" Width="16" Background="{DynamicResource SeparatorBrush}" Margin="0,0,0,0"/>
<Border x:Name="SplitDropDown">
<Path x:Name="DownArrow" Style="{DynamicResource DownArrowGeometryStyle}" Margin="4,4,4,0"/>
</Border>
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Image" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
<Setter TargetName="ToolBarSplitButtonContent" Property="Margin" Value="7,7,7,7"/>
</Trigger>
<Trigger Property="Text" Value="{x:Null}">
<Setter TargetName="ToolBarSplitButtonContent" Property="Margin" Value="0,0,0,0"/>
</Trigger>
<Trigger SourceName="PART_Button" Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Transparent" TargetName="SplitDropDown"/>
<Setter Property="Background" Value="{DynamicResource ToolBarButtonHover}" TargetName="PART_Button"/>
</Trigger>
<Trigger SourceName="PART_Button" Property="IsKeyboardFocused" Value="True">
<Setter Property="Background" Value="{DynamicResource ToolBarButtonHover}" TargetName="PART_Button"/>
</Trigger>
<Trigger SourceName="SplitDropDown" Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource ToolBarButtonHover}" TargetName="SplitDropDown"/>
<Setter Property="Background" Value="Transparent" TargetName="PART_Button"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="{DynamicResource ToolBarButtonHover}"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter Property="Background" Value="{DynamicResource ToolBarButtonHover}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
<Condition Property="IsChecked" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" Value="{DynamicResource ToolBarButtonHover}"/>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsKeyboardFocused" Value="True"/>
<Condition Property="IsChecked" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" Value="{DynamicResource ToolBarButtonHover}"/>
</MultiTrigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="{DynamicResource ToolBarButtonHover}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
示例 2: 樣本 XAML 程式碼定義了 ResourceDictionary、Style 和 Brush 資源,並演示了如何自定義 Main 工具列。
備註
您可以在 Unified Service Desk - 統一介面示例包中找到此示例 XAML 樣式。
<ResourceDictionary xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
xmlns:usd="clr-namespace:Microsoft.Crm.UnifiedServiceDesk.Dynamics;assembly=Microsoft.Crm.UnifiedServiceDesk.Dynamics"
xmlns:controlStyles="clr-namespace:Microsoft.Crm.UnifiedServiceDesk.Dynamics.Controls.Styles;assembly=Microsoft.Crm.UnifiedServiceDesk.Dynamics"
xmlns:usdPanelLayouts="clr-namespace:Microsoft.Crm.UnifiedServiceDesk.Dynamics.PanelLayouts;assembly=Microsoft.Crm.UnifiedServiceDesk.Dynamics"
xmlns:themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna"
xmlns:control="clr-namespace:Microsoft.Crm.UnifiedServiceDesk.Dynamics.Controls;assembly=Microsoft.Crm.UnifiedServiceDesk.Dynamics">
<Style x:Key="ToolBarMainPanelBorderStyle" TargetType="{x:Type Border}">
<Setter Property="Margin" Value="0,0,0,0"/>
<Setter Property="CornerRadius" Value="3,3,3,3"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
<Setter Property="CornerRadius" Value="0,0,0,0"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="ToolBarThumbStyle" TargetType="{x:Type Thumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border Background="Transparent" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
<Rectangle>
<Rectangle.Fill>
<DrawingBrush TileMode="Tile" Viewbox="0,0,4,4" Viewport="0,0,4,4" ViewportUnits="Absolute" ViewboxUnits="Absolute">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="White" Geometry="M 1 1 L 1 3 L 3 3 L 3 1 z"/>
<GeometryDrawing Brush="{DynamicResource ToolBarGripper}" Geometry="M 0 0 L 0 2 L 2 2 L 2 0 z"/>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Rectangle.Fill>
</Rectangle>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Cursor" Value="SizeAll"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ToolBarHorizontalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="MinHeight" Value="0"/>
<Setter Property="MinWidth" Value="0"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="Bd" Background="Transparent" CornerRadius="0" SnapsToDevicePixels="true">
<Image Source="{DynamicResource ImageMoreToolBarButtons}" Margin="7,5,7,5" Width="16" Height="16" VerticalAlignment="Bottom" HorizontalAlignment="Right"
AutomationProperties.Name="More Menu"></Image>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource USDTabBackgroundBrush}"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource USDTabBackgroundBrush}"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource ToolBarGripper}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
<Setter Property="Background" Value="Transparent"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="ToolBarVerticalOverflowButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Background" Value="{DynamicResource NormalBrush}"/>
<Setter Property="MinHeight" Value="0"/>
<Setter Property="MinWidth" Value="0"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Continue"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="Bd" Background="Transparent" CornerRadius="0" SnapsToDevicePixels="true">
<Image Source="{DynamicResource ImageMoreToolBarButtons}" Margin="7,5,7,5" Width="16" Height="16" VerticalAlignment="Bottom" HorizontalAlignment="Right"
AutomationProperties.Name="More Menu"></Image>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource USDTabBackgroundBrush}"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource USDTabBackgroundBrush}"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource ToolBarGripper}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
<Setter Property="Background" Value="Transparent"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type ToolBar}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Local"/>
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Continue"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToolBar}">
<Grid x:Name="Grid" Margin="0,0,0,0" SnapsToDevicePixels="true" Height="42">
<Grid x:Name="OverflowGrid" HorizontalAlignment="Right" Margin="0,0,-11,0">
<ToggleButton x:Name="OverflowButton" ClickMode="Press" FocusVisualStyle="{x:Null}" IsChecked="{Binding IsOverflowOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
IsEnabled="{TemplateBinding HasOverflowItems}" Style="{StaticResource ToolBarHorizontalOverflowButtonStyle}" Visibility="Collapsed"
Margin="0,0,0,5">
</ToggleButton>
<Popup x:Name="OverflowPopup" AllowsTransparency="true" Focusable="True" IsOpen="{Binding IsOverflowOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom" StaysOpen="false">
<themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">
<Border x:Name="ToolBarSubMenuBorder" BorderBrush="{DynamicResource ToolBarMenuBorder}" BorderThickness="1" Background="{DynamicResource ToolBarSubMenuBackground}" RenderOptions.ClearTypeHint="Enabled">
<ToolBarOverflowPanel x:Name="PART_ToolBarOverflowPanel" KeyboardNavigation.DirectionalNavigation="Continue" FocusVisualStyle="{x:Null}" Focusable="true" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.TabNavigation="Cycle" WrapWidth="200"/>
</Border>
</themes:SystemDropShadowChrome>
</Popup>
</Grid>
<Border x:Name="MainPanelBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" Style="{StaticResource ToolBarMainPanelBorderStyle}">
<DockPanel KeyboardNavigation.TabIndex="1" KeyboardNavigation.TabNavigation="Local">
<Thumb x:Name="ToolBarThumb" Margin="-3,-1,0,0" Padding="6,5,1,6" Style="{StaticResource ToolBarThumbStyle}"/>
<ContentPresenter x:Name="ToolBarHeader" ContentSource="Header" HorizontalAlignment="Center" Margin="4,0,4,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="Center"/>
<ToolBarPanel x:Name="PART_ToolBarPanel" IsItemsHost="true" Margin="0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</DockPanel>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasOverflowItems" Value="true">
<Setter Property="Visibility" TargetName="OverflowButton" Value="Visible"/>
</Trigger>
<Trigger Property="IsOverflowOpen" Value="true">
<Setter Property="IsEnabled" TargetName="ToolBarThumb" Value="false"/>
</Trigger>
<Trigger Property="Header" Value="{x:Null}">
<Setter Property="Visibility" TargetName="ToolBarHeader" Value="Collapsed"/>
</Trigger>
<Trigger Property="ToolBarTray.IsLocked" Value="true">
<Setter Property="Visibility" TargetName="ToolBarThumb" Value="Collapsed"/>
</Trigger>
<Trigger Property="HasDropShadow" SourceName="OverflowPopup" Value="true">
<Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
<Setter Property="SnapsToDevicePixels" TargetName="Shdw" Value="true"/>
<Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
</Trigger>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Margin" TargetName="Grid" Value="1,3,1,1"/>
<Setter Property="Style" TargetName="OverflowButton" Value="{StaticResource ToolBarVerticalOverflowButtonStyle}"/>
<Setter Property="Height" TargetName="ToolBarThumb" Value="10"/>
<Setter Property="Width" TargetName="ToolBarThumb" Value="Auto"/>
<Setter Property="Margin" TargetName="ToolBarThumb" Value="-1,-3,0,0"/>
<Setter Property="Padding" TargetName="ToolBarThumb" Value="5,6,6,1"/>
<Setter Property="Margin" TargetName="ToolBarHeader" Value="0,0,0,4"/>
<Setter Property="Margin" TargetName="PART_ToolBarPanel" Value="1,0,2,2"/>
<Setter Property="DockPanel.Dock" TargetName="ToolBarThumb" Value="Top"/>
<Setter Property="DockPanel.Dock" TargetName="ToolBarHeader" Value="Top"/>
<Setter Property="HorizontalAlignment" TargetName="OverflowGrid" Value="Stretch"/>
<Setter Property="VerticalAlignment" TargetName="OverflowGrid" Value="Bottom"/>
<Setter Property="Placement" TargetName="OverflowPopup" Value="Right"/>
<Setter Property="Margin" TargetName="MainPanelBorder" Value="0,0,0,11"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="KeyboardNavigation.TabNavigation" Value="Local"/>
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Continue"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding Source={x:Static SystemParameters.HighContrast}}" Value="true">
<Setter Property="Background" Value="Transparent"/>
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="ToolBarButtonBaseStyle">
<Setter Property="Control.BorderThickness" Value="0"/>
<Setter Property="Control.Padding" Value="0"/>
<Setter Property="Control.Background" Value="Transparent"/>
<Setter Property="Control.BorderBrush" Value="Transparent"/>
<Setter Property="Control.Foreground" Value="{DynamicResource ToolBarFontColor}"/>
<Setter Property="Control.FontFamily" Value="Segoe UI"/>
<Setter Property="Control.FontSize" Value="12"/>
</Style>
<Style x:Key="MainToolBarFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle SnapsToDevicePixels="true" Stroke="White"
StrokeDashArray="1 2" StrokeThickness="1"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ToolbarButtonTemplate" TargetType="{x:Type control:ToolbarButton}" BasedOn="{StaticResource ToolBarButtonBaseStyle}">
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontFamily" Value="Segoe UI"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FocusVisualStyle" Value="{DynamicResource MainToolBarFocusVisual}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type control:ToolbarButton}">
<Border x:Name="Bd" Height="42" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
<StackPanel x:Name="ToolBarButtonStackPanel" Orientation="Horizontal" Margin="14,0,14,0">
<Image Margin="0,0,7,0" x:Name="Icon" VerticalAlignment="Center" MaxWidth="16" MaxHeight="16" Source="{TemplateBinding Image}"/>
<ContentPresenter x:Name="ToolBarButtonContentPresenter" Margin="0,7,0,7" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</StackPanel>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Text" Value="{x:Null}">
<Setter TargetName="Icon" Property="Margin" Value="0,0,0,0"/>
</Trigger>
<Trigger Property="Image" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ToolBarButtonHover}"/>
<Setter Property="Foreground" Value="{DynamicResource ToolBarTextFontHighlightColor}"/>
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ToolBarButtonHover}"/>
<Setter Property="Foreground" Value="{DynamicResource ToolBarTextFontHighlightColor}"/>
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ToolBarButtonPressed}"/>
<Setter Property="Foreground" Value="{DynamicResource ToolBarButtonHover}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ToolBarDropDownButtonStyle" TargetType="{x:Type control:DropDownButton}" BasedOn="{StaticResource ToolBarButtonBaseStyle}">
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="FontFamily" Value="Segoe UI"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FocusVisualStyle" Value="{DynamicResource MainToolBarFocusVisual}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type control:DropDownButton}">
<Border SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<!--<Label>-->
<StackPanel Orientation="Horizontal" Margin="14,0,14,0">
<Image Margin="0,0,7,0" x:Name="Icon" VerticalAlignment="Center" Width="16" Height="16" Source="{TemplateBinding Image}"/>
<ContentPresenter Margin="{TemplateBinding Margin}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
<Path x:Name="DownArrow" Style="{DynamicResource DownArrowGeometryStyle}" Margin="7,4,0,0"/>
</StackPanel>
<!--</Label>-->
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Text" Value="{x:Null}">
<Setter TargetName="Icon" Property="Margin" Value="0,0,0,0"/>
</Trigger>
<Trigger Property="Image" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="{DynamicResource ToolBarButtonHover}"/>
<Setter TargetName="DownArrow" Property="Stroke" Value="{DynamicResource ToolBarButtonHover}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="{DynamicResource ToolBarButtonHover}"/>
<Setter Property="Foreground" Value="{DynamicResource ToolBarTextFontHighlightColor}"/>
<Setter TargetName="DownArrow" Property="Stroke" Value="{DynamicResource ToolBarTextFontHighlightColor}" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter Property="Background" Value="{DynamicResource ToolBarButtonHover}"/>
<Setter Property="Foreground" Value="{DynamicResource ToolBarTextFontHighlightColor}"/>
<Setter TargetName="DownArrow" Property="Stroke" Value="{DynamicResource ToolBarTextFontHighlightColor}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True"/>
<Condition Property="IsChecked" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" Value="{DynamicResource ToolBarSplitButtonSelectedBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource ToolBarTextFontHighlightColor}"/>
<Setter TargetName="DownArrow" Property="Stroke" Value="{DynamicResource ToolBarTextFontHighlightColor}" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsKeyboardFocused" Value="True"/>
<Condition Property="IsChecked" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="{DynamicResource ToolBarButtonHover}"/>
<Setter TargetName="DownArrow" Property="Stroke" Value="{DynamicResource ToolBarButtonHover}" />
</MultiTrigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="{DynamicResource ToolBarButtonHover}"/>
<Setter TargetName="DownArrow" Property="Stroke" Value="{DynamicResource ToolBarButtonHover}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>