版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
第WPF實(shí)現(xiàn)環(huán)(圓)形菜單的示例代碼2.CircularMenuItemCustomControlStyle.xaml
ResourceDictionaryxmlns="/winfx/2006/xaml/presentation"
xmlns:x="/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfCircularMenu"
StyleTargetType="{x:Typelocal:CircularMenuItemCustomControl}"
SetterProperty="Template"
Setter.Value
ControlTemplateTargetType="local:CircularMenuItemCustomControl"
GridVerticalAlignment="Center"
Grid.RenderTransform
RotateTransformx:Name="PART_RotateTransform"Angle="{TemplateBindingAngle}"CenterX="200"CenterY="200"/RotateTransform
/Grid.RenderTransform
Pathx:Name="PART_Path"Data="M200,2000,200A200,20000158.6,58.6z"
Fill="{TemplateBindingBackgroundColor}"VerticalAlignment="Center"/
ImageSource="{TemplateBindingIconImage}"RenderTransformOrigin="0.5,0.5"
Margin="60,70,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Width="40"Height="40"
Image.RenderTransform
RotateTransformAngle="-70"/
/Image.RenderTransform
/Image
/Grid
ControlTemplate.Triggers
TriggerProperty="IsMouseOver"Value="true"
SetterTargetName="PART_Path"Property="Fill"Value="#009AD8"/
SetterProperty="Cursor"Value="Hand"/
/Trigger
/ControlTemplate.Triggers
/ControlTemplate
/Setter.Value
/Setter
/Style
/ResourceDictionary
3.MainWindow.xaml
Windowx:xmlns="/winfx/2006/xaml/presentation"
xmlns:x="/winfx/2006/xaml"
xmlns:d="/expression/blend/2008"
xmlns:mc="/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfCircularMenu"
mc:Ignorable="d"
Title="MainWindow"Height="850"Width="1200"
Background="Black"
SnapsToDevicePixels="True"
TextOptions.TextFormattingMode="Display"
UseLayoutRounding="True"
Window.Resources
Storyboardx:Key="CheckedStoryboard"
DoubleAnimationStoryboard.TargetName="PART_EllipseGeometry"
Storyboard.TargetProperty="RadiusX"
Duration="00:00:0.4"To="200"/
DoubleAnimationStoryboard.TargetName="PART_EllipseGeometry"
Storyboard.TargetProperty="RadiusY"
Duration="00:00:0.4"To="200"/
/Storyboard
Storyboardx:Key="UncheckedStoryboard"
DoubleAnimationStoryboard.TargetName="PART_EllipseGeometry"
Storyboard.TargetProperty="RadiusX"
Duration="00:00:0.3"To="0"/
DoubleAnimationStoryboard.TargetName="PART_EllipseGeometry"
Storyboard.TargetProperty="RadiusY"
Duration="00:00:0.3"To="0"/
/Storyboard
/Window.Resources
Viewbox
GridHeight="768"Width="1024"
Canvas
ItemsControlItemsSource="{BindingMenuArray,RelativeSource={RelativeSourceAncestorType=local:MainWindow}}"
Canvas.Left="150"Canvas.Top="150"
ItemsControl.Clip
EllipseGeometryx:Name="PART_EllipseGeometry"RadiusX="0"RadiusY="0"Center="200,200"/EllipseGeometry
/ItemsControl.Clip
ItemsControl.ItemTemplate
DataTemplate
local:CircularMenuItemCustomControlAngle="{BindingAngle}"MenuTxt="{BindingTitle}"
BackgroundColor="{BindingFillColor}"IconImage="{BindingIconImage}"/
/DataTemplate
/ItemsControl.ItemTemplate
ItemsControl.ItemsPanel
ItemsPanelTemplate
Grid/
/ItemsPanelTemplate
/ItemsControl.ItemsPanel
/ItemsControl
ToggleButtonCanvas.Left="300"Canvas.Top="300"Cursor="Hand"
ToggleButton.Template
ControlTemplateTargetType="ToggleButton"
Grid
Ellipsex:Name="PART_Ellipse"Width="100"Height="100"Fill="#009AD8"ToolTip="關(guān)閉"/
Pathx:Name="PART_Path"Data="M734.618760.269c-24.01324.013-62.92524.013-86.8860l-135.731-155.136-135.731155.085c-24.01324.013-62.92524.013-86.8860-24.013-24.013-24.013-62.9250-86.886l141.21-161.28-141.261-161.382c-24.013-24.013-24.013-62.8740-86.886s62.874-24.01386.8860l135.782155.187135.731-155.187c24.013-24.01362.874-24.01386.8860s24.01362.925086.886l-141.21161.382141.21161.28c24.01324.01324.01362.925086.938z"
Fill="White"Stretch="Fill"Width="20"Height="20"RenderTransformOrigin="0.5,0.5"IsHitTestVisible="False"
/Path
/Grid
ControlTemplate.Triggers
TriggerProperty="IsChecked"Value="false"
SetterTargetName="PART_Path"Property="RenderTransform"
Setter.Value
RotateTransformAngle="45"/
/Setter.Value
/Setter
SetterProperty="ToolTip"TargetName="PART_Ellipse"Value="展開(kāi)"/
/Trigger
/ControlTemplate.Triggers
/ControlTemplate
/ToggleButton.Template
ToggleButton.Triggers
EventTriggerRoutedEvent="ToggleButton.Checked"
BeginStoryboardStoryboard="{StaticResourceCheckedStoryboard}"/
/EventTrigger
EventTriggerRoutedEvent="ToggleButton.Unchecked"
BeginStoryboardStoryboard="{StaticResourceUncheckedStoryboard}"/
/EventTrigger
/ToggleButton.Triggers
/ToggleButton
TextBlockText="微信公眾號(hào):WPF開(kāi)發(fā)者"FontSize="40"
Foreground="#A9CC32"FontWeight="Bold"
Canvas.Top="50"/
ImageSource="Images/gzh.png"Canvas.Left="140"Canvas.Bottom="40"/
/Canvas
/Grid
/Viewbox
/Window
4.MainWindow.xaml.cs
Windowx:xmlns="/winfx/2006/xaml/presentation"
xmlns:x="/winfx/2006/xaml"
xmlns:d="/expression/blend/2008"
xmlns:mc="/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfCircularMenu"
mc:Ignorable="d"
Title="MainWindow"Height="850"Width="1200"
Background="Black"
SnapsToDevicePixels="True"
TextOptions.TextFormattingMode="Display"
UseLayoutRounding="True"
Window.Resources
Storyboardx:Key="CheckedStoryboard"
DoubleAnimationStoryboard.TargetName="PART_EllipseGeometry"
Storyboard.TargetProperty="RadiusX"
Duration="00:00:0.4"To="200"/
DoubleAnimationStoryboard.TargetName="PART_EllipseGeometry"
Storyboard.TargetProperty="RadiusY"
Duration="00:00:0.4"To="200"/
/Storyboard
Storyboardx:Key="UncheckedStoryboard"
DoubleAnimationStoryboard.TargetName="PART_EllipseGeometry"
Storyboard.TargetProperty="RadiusX"
Duration="00:00:0.3"To="0"/
DoubleAnimationStoryboard.TargetName="PART_EllipseGeometry"
Storyboard.TargetProperty="RadiusY"
Duration="00:00:0.3"To="0"/
/Storyboard
/Window.Resources
Viewbox
GridHeight="768"Width="1024"
Canvas
ItemsControlItemsSource="{BindingMenuArray,RelativeSource={RelativeSourceAncestorType=local:MainWindow}}"
Canvas.Left="150"Canvas.Top="150"
ItemsControl.Clip
EllipseGeometryx:Name="PART_EllipseGeometry"RadiusX="0"RadiusY="0"Center="200,200"/EllipseGeometry
/ItemsControl.Clip
ItemsControl.ItemTemplate
DataTemplate
local:CircularMenuItemCustomControlAngle="{BindingAngle}"MenuTxt="{BindingTitle}"
BackgroundColor="{BindingFillColor}"IconImage="{BindingIconImage}"/
/DataTemplate
/ItemsControl.ItemTemplate
ItemsControl.ItemsPanel
ItemsPanelTemplate
Grid/
/ItemsPanelTemplate
/ItemsControl.ItemsPanel
/ItemsControl
ToggleButtonCanvas.Left="300"Canvas.Top="300"Cursor="Hand"
ToggleButton.Template
ControlTemplateTargetType="ToggleButton"
Grid
Ellipsex:Name="PART_Ellipse"Width="100"Height="100"Fill="#009AD8"ToolTip="關(guān)閉"/
Pathx:Name="PART_Path"Data="M734.618760.269c-24.01324.013-62.92524.013-86.8860l-135.731-155.136-135.731155.085c-24.01324.013-62.92524.013-86.8860-24.013-24.013-24.013-62.9250-86.886l141.21-161.28-141.261-161.382c-24.013-24.013-24.013-62.8740-86.886s62.874-24.01386.8860l135.782155.187135.731-155.187c24.013-24.01362.874-24.01386.8860s24.01362.925086.886l-141.21161.382141.21161.28c24.01324.01324.01362.925086.938z"
Fill="White"Stretch="Fill"Width="20"Height="20"RenderTransformOrigin="0.5,0.5"IsHitTestVisible="False"
/Path
/Grid
ControlTemplate.Triggers
TriggerProperty="IsChecked"Value="false"
SetterTa
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 學(xué)校夜間值班保衛(wèi)制度
- 高難度物理學(xué)題目及答案
- 養(yǎng)老院膳食營(yíng)養(yǎng)制度
- 養(yǎng)老院內(nèi)部保衛(wèi)制度
- 大足駕校文盲考試題目及答案
- 現(xiàn)代詩(shī)兩首題目及答案
- 聚眾賭博面試題目及答案
- 辦公室員工培訓(xùn)與考核制度
- 閉環(huán)消缺制度
- 能源管理服務(wù)協(xié)議(2025年執(zhí)行版)
- 2026年山東省威海市單招職業(yè)傾向性測(cè)試題庫(kù)附答案解析
- 2026新疆伊犁州新源縣總工會(huì)面向社會(huì)招聘工會(huì)社會(huì)工作者3人考試備考試題及答案解析
- 積極思想培訓(xùn)
- 2026春譯林8下單詞表【Unit1-8】(可編輯版)
- 2026年《必背60題》抖音本地生活BD經(jīng)理高頻面試題包含詳細(xì)解答
- 駱駝祥子劇本殺課件
- 電影短片拍攝實(shí)踐課件
- 2025首都文化科技集團(tuán)有限公司招聘9人考試筆試備考題庫(kù)及答案解析
- 《經(jīng)典常談》導(dǎo)讀課件教學(xué)
- 農(nóng)業(yè)科技合作協(xié)議2025
- 護(hù)理文書(shū)書(shū)寫規(guī)范與法律風(fēng)險(xiǎn)規(guī)避
評(píng)論
0/150
提交評(píng)論