• WPF 实现抽屉菜单


     分享一个WPF 实现抽屉菜单

    抽屉菜单

    作者:WPFDevelopersOrg

    原文链接:https://github.com/WPFDevelopersOrg/WPFDevelopers

    • 框架使用大于等于.NET40

    • Visual Studio 2022;

    • 项目使用 MIT 开源许可协议;

    • 更多效果可以通过GitHub[1]|码云[2]下载代码;

    • 由于在WPF中没有现成的类似UWP的抽屉菜单,所以我们自己实现一个。

    1) DrawerMenu.cs 代码如下。

    1. using System.Collections.Generic;
    2. using System.Windows;
    3. using System.Windows.Controls;
    4. using System.Windows.Media;
    5. namespace WPFDevelopers.Controls
    6. {
    7.     public class DrawerMenu : ContentControl
    8.     {
    9.         public new static readonly DependencyProperty ContentProperty =
    10.             DependencyProperty.Register("Content"typeof(List), typeof(DrawerMenu),
    11.                 new FrameworkPropertyMetadata(null));
    12.         public static readonly DependencyProperty IsOpenProperty =
    13.             DependencyProperty.Register("IsOpen"typeof(bool), typeof(DrawerMenu), new PropertyMetadata(true));
    14.         public static readonly DependencyProperty MenuIconColorProperty =
    15.             DependencyProperty.Register("MenuIconColor"typeof(Brush), typeof(DrawerMenu),
    16.                 new PropertyMetadata(Brushes.White));
    17.         public static readonly DependencyProperty SelectionIndicatorColorProperty =
    18.             DependencyProperty.Register("SelectionIndicatorColor"typeof(Brush), typeof(DrawerMenu),
    19.                 new PropertyMetadata(DrawingContextHelper.Brush));
    20.         public static readonly DependencyProperty MenuItemForegroundProperty =
    21.             DependencyProperty.Register("MenuItemForeground"typeof(Brush), typeof(DrawerMenu),
    22.                 new PropertyMetadata(Brushes.Transparent));
    23.         static DrawerMenu()
    24.         {
    25.             DefaultStyleKeyProperty.OverrideMetadata(typeof(DrawerMenu),
    26.                 new FrameworkPropertyMetadata(typeof(DrawerMenu)));
    27.         }
    28.         public new List Content
    29.         {
    30.             get => (List)GetValue(ContentProperty);
    31.             set => SetValue(ContentProperty, value);
    32.         }
    33.         public bool IsOpen
    34.         {
    35.             get => (bool)GetValue(IsOpenProperty);
    36.             set => SetValue(IsOpenProperty, value);
    37.         }
    38.         public Brush MenuIconColor
    39.         {
    40.             get => (Brush)GetValue(MenuIconColorProperty);
    41.             set => SetValue(MenuIconColorProperty, value);
    42.         }
    43.         public Brush SelectionIndicatorColor
    44.         {
    45.             get => (Brush)GetValue(SelectionIndicatorColorProperty);
    46.             set => SetValue(SelectionIndicatorColorProperty, value);
    47.         }
    48.         public Brush MenuItemForeground
    49.         {
    50.             get => (Brush)GetValue(MenuItemForegroundProperty);
    51.             set => SetValue(MenuItemForegroundProperty, value);
    52.         }
    53.         public override void BeginInit()
    54.         {
    55.             Content = new List();
    56.             base.BeginInit();
    57.         }
    58.     }
    59. }

    2) DrawerMenuItem.cs 代码如下。

    1. using System.Windows;
    2. using System.Windows.Controls;
    3. using System.Windows.Input;
    4. using System.Windows.Media;
    5. namespace WPFDevelopers.Controls
    6. {
    7.     public class DrawerMenuItem : ListBoxItem
    8.     {
    9.         public static readonly DependencyProperty TextProperty =
    10.             DependencyProperty.Register("Text"typeof(string), typeof(DrawerMenuItem),
    11.                 new PropertyMetadata(string.Empty));
    12.         public static readonly DependencyProperty IconProperty =
    13.             DependencyProperty.Register("Icon"typeof(ImageSource), typeof(DrawerMenuItem),
    14.                 new PropertyMetadata(null));
    15.         public static readonly DependencyProperty SelectionIndicatorColorProperty =
    16.             DependencyProperty.Register("SelectionIndicatorColor"typeof(Brush), typeof(DrawerMenuItem),
    17.                 new PropertyMetadata(DrawingContextHelper.Brush));
    18.         public static readonly DependencyProperty SelectionCommandProperty =
    19.             DependencyProperty.Register("SelectionCommand"typeof(ICommand), typeof(DrawerMenuItem),
    20.                 new PropertyMetadata(null));
    21.         static DrawerMenuItem()
    22.         {
    23.             DefaultStyleKeyProperty.OverrideMetadata(typeof(DrawerMenuItem),
    24.                 new FrameworkPropertyMetadata(typeof(DrawerMenuItem)));
    25.         }
    26.         public string Text
    27.         {
    28.             get => (string)GetValue(TextProperty);
    29.             set => SetValue(TextProperty, value);
    30.         }
    31.         public ImageSource Icon
    32.         {
    33.             get => (ImageSource)GetValue(IconProperty);
    34.             set => SetValue(IconProperty, value);
    35.         }
    36.         public Brush SelectionIndicatorColor
    37.         {
    38.             get => (Brush)GetValue(SelectionIndicatorColorProperty);
    39.             set => SetValue(SelectionIndicatorColorProperty, value);
    40.         }
    41.         public ICommand SelectionCommand
    42.         {
    43.             get => (ICommand)GetValue(SelectionCommandProperty);
    44.             set => SetValue(SelectionCommandProperty, value);
    45.         }
    46.     }
    47. }

    3) DrawerMenu.xaml 代码如下。

    1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    2.                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    3.                     xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
    4.                     xmlns:controls="clr-namespace:WPFDevelopers.Controls">
    5.     <ResourceDictionary.MergedDictionaries>
    6.         <ResourceDictionary Source="Basic/ControlBasic.xaml"/>
    7.     ResourceDictionary.MergedDictionaries>
    8.     <Style x:Key="DrawerMenuToggleButton" TargetType="ToggleButton" BasedOn="{StaticResource ControlBasicStyle}">
    9.         <Setter Property="IsChecked" Value="False"/>
    10.         <Setter Property="Template">
    11.             <Setter.Value>
    12.                 <ControlTemplate TargetType="{x:Type ToggleButton}">
    13.                     <Grid Background="{TemplateBinding Background}">
    14.                         <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
    15.                     Grid>
    16.                 ControlTemplate>
    17.             Setter.Value>
    18.         Setter>
    19.         <Style.Triggers>
    20.             <Trigger Property="IsMouseOver" Value="True">
    21.                 <Setter Property="Opacity" Value="0.8" />
    22.                 <Setter Property="Cursor" Value="Hand" />
    23.                 <Setter Property="Template">
    24.                     <Setter.Value>
    25.                         <ControlTemplate TargetType="{x:Type ToggleButton}">
    26.                             <Border
    27.                                         Background="{TemplateBinding Background}"
    28.                                         BorderBrush="Black"
    29.                                         BorderThickness="1">
    30.                                 <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
    31.                             Border>
    32.                         ControlTemplate>
    33.                     Setter.Value>
    34.                 Setter>
    35.             Trigger>
    36.         Style.Triggers>
    37.     Style>
    38.     <Style x:Key="DrawerMenuListBox" TargetType="ListBox" BasedOn="{StaticResource ControlBasicStyle}">
    39.         <Setter Property="Background" Value="Transparent" />
    40.         <Setter Property="BorderBrush" Value="Transparent" />
    41.         <Setter Property="BorderThickness" Value="0"/>
    42.         <Setter Property="Template">
    43.             <Setter.Value>
    44.                 <ControlTemplate>
    45.                     <ScrollViewer>
    46.                         <ItemsPresenter Margin="0" />
    47.                     ScrollViewer>
    48.                 ControlTemplate>
    49.             Setter.Value>
    50.         Setter>
    51.     Style>
    52.     <Style x:Key="ButtonFocusVisual">
    53.         <Setter Property="Control.Template">
    54.             <Setter.Value>
    55.                 <ControlTemplate>
    56.                     <Border>
    57.                         <Rectangle 
    58.             Margin="2"
    59.             StrokeThickness="1"
    60.             Stroke="#60000000"
    61.             StrokeDashArray="1 2"/>
    62.                     Border>
    63.                 ControlTemplate>
    64.             Setter.Value>
    65.         Setter>
    66.     Style>
    67.     
    68.     <SolidColorBrush x:Key="NormalBrush" Color="Transparent"  po:Freeze="True"/>
    69.     <SolidColorBrush x:Key="DarkBrush" Color="#ddd"  po:Freeze="True"/>
    70.     <SolidColorBrush x:Key="PressedBrush" Color="#80FFFFFF"  po:Freeze="True"/>
    71.     <SolidColorBrush x:Key="DisabledForegroundBrush" Color="Transparent"  po:Freeze="True"/>
    72.     <SolidColorBrush x:Key="DisabledBackgroundBrush" Color="Transparent"  po:Freeze="True"/>
    73.     
    74.     <SolidColorBrush x:Key="NormalBorderBrush" Color="Transparent"  po:Freeze="True"/>
    75.     <SolidColorBrush x:Key="PressedBorderBrush" Color="Transparent"  po:Freeze="True"/>
    76.     <SolidColorBrush x:Key="DefaultedBorderBrush" Color="Transparent"  po:Freeze="True"/>
    77.     <SolidColorBrush x:Key="DisabledBorderBrush" Color="Transparent"  po:Freeze="True"/>
    78.     <Style x:Key="DrawerMenuItemButtonStyle" TargetType="Button" BasedOn="{StaticResource ControlBasicStyle}">
    79.         <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
    80.         <Setter Property="MinHeight" Value="23"/>
    81.         <Setter Property="MinWidth" Value="75"/>
    82.         <Setter Property="Cursor" Value="Hand" />
    83.         <Setter Property="Template">
    84.             <Setter.Value>
    85.                 <ControlTemplate TargetType="Button">
    86.                     <Border 
    87.           x:Name="Border"  
    88.           CornerRadius="0" 
    89.           BorderThickness="0"
    90.           Background="Transparent"
    91.           BorderBrush="Transparent">
    92.                         <ContentPresenter 
    93.             HorizontalAlignment="Stretch"
    94.             VerticalAlignment="Stretch"
    95.             RecognizesAccessKey="True"/>
    96.                     Border>
    97.                     <ControlTemplate.Triggers>
    98.                         <Trigger Property="IsKeyboardFocused" Value="true">
    99.                             <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource DefaultedBorderBrush}" />
    100.                         Trigger>
    101.                         <Trigger Property="IsDefaulted" Value="true">
    102.                             <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource DefaultedBorderBrush}" />
    103.                         Trigger>
    104.                         <Trigger Property="IsMouseOver" Value="true">
    105.                             <Setter TargetName="Border" Property="Background" Value="{DynamicResource DarkBrush}" />
    106.                         Trigger>
    107.                         <Trigger Property="IsPressed" Value="true">
    108.                             <Setter TargetName="Border" Property="Background" Value="{DynamicResource PressedBrush}" />
    109.                             <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource PressedBorderBrush}" />
    110.                         Trigger>
    111.                         <Trigger Property="IsEnabled" Value="false">
    112.                             <Setter TargetName="Border" Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" />
    113.                             <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource DisabledBorderBrush}" />
    114.                             <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
    115.                         Trigger>
    116.                     ControlTemplate.Triggers>
    117.                 ControlTemplate>
    118.             Setter.Value>
    119.         Setter>
    120.     Style>
    121.     <Style TargetType="controls:DrawerMenuItem">
    122.         <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    123.         <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:DrawerMenu}}, Path=MenuItemForeground}"/>
    124.         <Setter Property="SelectionIndicatorColor" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:DrawerMenu}}, Path=SelectionIndicatorColor}"/>
    125.         <Setter Property="Template">
    126.             <Setter.Value>
    127.                 <ControlTemplate TargetType="controls:DrawerMenuItem">
    128.                     <Button x:Name="PART_Button" Height="44"
    129.                             Command="{TemplateBinding SelectionCommand}" 
    130.                             ToolTip="{TemplateBinding Text}"
    131.                             HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
    132.                             Style="{StaticResource DrawerMenuItemButtonStyle}">
    133.                         <Grid>
    134.                             <Grid.ColumnDefinitions>
    135.                                 <ColumnDefinition Width="5"/>
    136.                                 <ColumnDefinition/>
    137.                             Grid.ColumnDefinitions>
    138.                             <Grid Grid.ColumnSpan="2">
    139.                                 <Grid Width="300">
    140.                                     <Grid.ColumnDefinitions>
    141.                                         <ColumnDefinition Width="45"/>
    142.                                         <ColumnDefinition/>
    143.                                     Grid.ColumnDefinitions>
    144.                                     <Image Grid.Column="0" Source="{TemplateBinding Icon}" Margin="10,5,5,5"/>
    145.                                     <TextBlock Text="{TemplateBinding Text}" Grid.Column="1"
    146.                                                    Margin="10,0,0,0" HorizontalAlignment="Left" 
    147.                                                    VerticalAlignment="Center" 
    148.                                                    FontSize="{StaticResource TitleFontSize}"
    149.                                                    Foreground="{TemplateBinding Foreground}"
    150.                                                    TextWrapping="Wrap"/>
    151.                                 Grid>
    152.                             Grid>
    153.                             <Grid Name="PART_ItemSelectedIndicator" 
    154.                                   Grid.Column="0" 
    155.                                   Background="{TemplateBinding SelectionIndicatorColor}" 
    156.                                   Visibility="Collapsed" />
    157.                         Grid>
    158.                     Button>
    159.                     <ControlTemplate.Triggers>
    160.                         <Trigger Property="IsSelected" Value="True">
    161.                             <Setter TargetName="PART_ItemSelectedIndicator" Property="Visibility" Value="Visible" />
    162.                         Trigger>
    163.                         <Trigger SourceName="PART_Button" Property="IsPressed" Value="True">
    164.                             <Trigger.ExitActions>
    165.                                 <BeginStoryboard>
    166.                                     <Storyboard>
    167.                                         <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="IsSelected">
    168.                                             <DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="True" />
    169.                                         BooleanAnimationUsingKeyFrames>
    170.                                     Storyboard>
    171.                                 BeginStoryboard>
    172.                             Trigger.ExitActions>
    173.                         Trigger>
    174.                     ControlTemplate.Triggers>
    175.                 ControlTemplate>
    176.             Setter.Value>
    177.         Setter>
    178.     Style>
    179.     <Style TargetType="controls:DrawerMenu">
    180.         <Setter Property="Width" Value="50"/>
    181.         <Setter Property="Visibility" Value="Visible"/>
    182.         <Setter Property="IsOpen" Value="True"/>
    183.         <Setter Property="Template">
    184.             <Setter.Value>
    185.                 <ControlTemplate TargetType="controls:DrawerMenu">
    186.                     <Grid Background="{TemplateBinding Background}">
    187.                         <ToggleButton HorizontalAlignment="Left" Background="#333"
    188.                                       VerticalAlignment="Top" Height="40" Width="50"
    189.                                       IsChecked="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:DrawerMenu}}, Path=IsOpen}"
    190.                                       Style="{StaticResource DrawerMenuToggleButton}">
    191.                             <Path HorizontalAlignment="Center" 
    192.                                   VerticalAlignment="Center" 
    193.                                   Stretch="Uniform" Width="20" 
    194.                                   Fill="{TemplateBinding MenuIconColor}"
    195.                                   Data="{StaticResource PathMenu}"/>
    196.                         ToggleButton>
    197.                         <ListBox ItemsSource="{TemplateBinding Content}" 
    198.                                  HorizontalAlignment="Left" Margin="0,40,0,0" 
    199.                                  VerticalAlignment="Top" 
    200.                                  Style="{StaticResource DrawerMenuListBox}"
    201.                                  ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
    202.                                  SelectedIndex="0"/>
    203.                     Grid>
    204.                 ControlTemplate>
    205.             Setter.Value>
    206.         Setter>
    207.         <Style.Triggers>
    208.             <Trigger Property="IsOpen" Value="False">
    209.                 <Trigger.EnterActions>
    210.                     <BeginStoryboard>
    211.                         <Storyboard>
    212.                             <DoubleAnimation 
    213.                                          Storyboard.TargetProperty="Width"
    214.                                          To="180"
    215.                                          Duration="0:0:0.2"/>
    216.                         Storyboard>
    217.                     BeginStoryboard>
    218.                 Trigger.EnterActions>
    219.                 <Trigger.ExitActions>
    220.                     <BeginStoryboard>
    221.                         <Storyboard>
    222.                             <DoubleAnimation 
    223.                                          Storyboard.TargetProperty="Width"
    224.                                          To="50"
    225.                                          Duration="0:0:0.2"/>
    226.                         Storyboard>
    227.                     BeginStoryboard>
    228.                 Trigger.ExitActions>
    229.             Trigger>
    230.         Style.Triggers>
    231.     Style>
    232. ResourceDictionary>

    4) DrawerMenuExample.xaml 代码如下。

    1. <UserControl x:Class="WPFDevelopers.Samples.ExampleViews.DrawerMenu.DrawerMenuExample"
    2.              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    3.              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    4.              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    5.              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    6.              xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews.DrawerMenu"
    7.              xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
    8.              mc:Ignorable="d" 
    9.              d:DesignHeight="450" d:DesignWidth="800">
    10.     <Grid Background="#FF7B7BFF">
    11.         <Grid.ColumnDefinitions>
    12.             <ColumnDefinition  Width="Auto"/>
    13.             <ColumnDefinition/>
    14.         Grid.ColumnDefinitions>
    15.         <wpfdev:DrawerMenu Background="#eee"
    16.                           SelectionIndicatorColor="{StaticResource PrimaryPressedSolidColorBrush}" 
    17.                           MenuItemForeground="{StaticResource BlackSolidColorBrush}" HorizontalAlignment="Left">
    18.             <wpfdev:DrawerMenu.Content>
    19.                 <wpfdev:DrawerMenuItem Icon="pack://application:,,,/Images/CircularMenu/2.png" Text="主页"
    20.                                       SelectionCommand="{Binding HomeCommand,RelativeSource={RelativeSource AncestorType=local:DrawerMenuExample}}"/>
    21.                 <wpfdev:DrawerMenuItem Icon="pack://application:,,,/Images/CircularMenu/4.png" Text="Edge"
    22.                                       SelectionCommand="{Binding EdgeCommand,RelativeSource={RelativeSource AncestorType=local:DrawerMenuExample}}"/>
    23.                 <wpfdev:DrawerMenuItem Icon="pack://application:,,,/Images/CircularMenu/1.png" Text="云盘"
    24.                                       SelectionCommand="{Binding CloudCommand,RelativeSource={RelativeSource AncestorType=local:DrawerMenuExample}}"/>
    25.                 <wpfdev:DrawerMenuItem Icon="pack://application:,,,/Images/CircularMenu/8.png" Text="邮件"
    26.                                       SelectionCommand="{Binding MailCommand,RelativeSource={RelativeSource AncestorType=local:DrawerMenuExample}}"/>
    27.                 <wpfdev:DrawerMenuItem Icon="pack://application:,,,/Images/CircularMenu/6.png" Text="视频"
    28.                                       SelectionCommand="{Binding VideoCommand,RelativeSource={RelativeSource AncestorType=local:DrawerMenuExample}}"/>
    29.             wpfdev:DrawerMenu.Content>
    30.         wpfdev:DrawerMenu>
    31.         <Frame Name="myFrame" Grid.Column="1" Margin="0,40,0,0"
    32.                NavigationUIVisibility="Hidden">Frame>
    33.     Grid>
    34. UserControl>

    5) DrawerMenuExample.xaml.cs 代码如下。

    1. using System;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using System.Windows;
    5. using System.Windows.Controls;
    6. using System.Windows.Input;
    7. using System.Windows.Media;
    8. using WPFDevelopers.Samples.Helpers;
    9. namespace WPFDevelopers.Samples.ExampleViews.DrawerMenu
    10. {
    11.     /// 
    12.     /// Win10MenuExample.xaml 的交互逻辑
    13.     /// 
    14.     public partial class DrawerMenuExample : UserControl
    15.     {
    16.         private List _uriList = new List()
    17.         {
    18.             new Uri("ExampleViews/DrawerMenu/HomePage.xaml",UriKind.Relative),
    19.             new Uri("ExampleViews/DrawerMenu/EdgePage.xaml",UriKind.Relative),
    20.         };
    21.         public DrawerMenuExample()
    22.         {
    23.             InitializeComponent();
    24.             myFrame.Navigate(_uriList[0]);
    25.         }
    26.         public ICommand HomeCommand => new RelayCommand(obj =>
    27.         {
    28.             myFrame.Navigate(_uriList[0]);
    29.         });
    30.         public ICommand EdgeCommand => new RelayCommand(obj =>
    31.         {
    32.             myFrame.Navigate(_uriList[1]);
    33.         });
    34.         public ICommand CloudCommand => new RelayCommand(obj =>
    35.         {
    36.             WPFDevelopers.Minimal.Controls.MessageBox.Show("点击了云盘","提示");
    37.         });
    38.         public ICommand MailCommand => new RelayCommand(obj =>
    39.         {
    40.             WPFDevelopers.Minimal.Controls.MessageBox.Show("点击了邮件","提示");
    41.         });
    42.         public ICommand VideoCommand => new RelayCommand(obj =>
    43.         {
    44.             WPFDevelopers.Minimal.Controls.MessageBox.Show("点击了视频","提示");
    45.         });
    46.     }
    47. }

    6) HomePage.xaml.cs 代码如下。

    1. <Page x:Class="WPFDevelopers.Samples.ExampleViews.DrawerMenu.HomePage"
    2.       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    3.       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    4.       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    5.       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    6.       xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews.DrawerMenu"
    7.       mc:Ignorable="d" 
    8.       d:DesignHeight="450" d:DesignWidth="800"
    9.       Title="HomePage" Background="{StaticResource PrimaryTextSolidColorBrush}">
    10.     <Grid>
    11.         <TextBlock VerticalAlignment="Center"
    12.                    HorizontalAlignment="Center"
    13.                    Width="400" TextAlignment="Center"
    14.                    TextWrapping="Wrap"
    15.                    Margin="0,0,0,40"
    16.                    FontSize="{StaticResource NormalFontSize}">
    17.             <Run Foreground="White">HomeRun>
    18.             <Run Text="微信公众号 WPFDevelopers" FontSize="40"
    19.                            Foreground="#A9CC32" FontWeight="Bold">Run>
    20.             <LineBreak/>
    21.             <Hyperlink NavigateUri="https://github.com/WPFDevelopersOrg/WPFDevelopers.git"
    22.                        RequestNavigate="GithubHyperlink_RequestNavigate"> Github 源代码Hyperlink>
    23.             <Run/>
    24.             <Run/>
    25.             <Run/>
    26.             <Hyperlink NavigateUri="https://gitee.com/yanjinhua/WPFDevelopers.git"
    27.                        RequestNavigate="GiteeHyperlink_RequestNavigate"> 码云源代码Hyperlink>
    28.         TextBlock>
    29.     Grid>
    30. Page>

    7) EdgePage.xaml.cs 代码如下。

    1. <Page x:Class="WPFDevelopers.Samples.ExampleViews.DrawerMenu.EdgePage"
    2.       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    3.       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    4.       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    5.       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    6.       xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews.DrawerMenu"
    7.       mc:Ignorable="d" 
    8.       d:DesignHeight="450" d:DesignWidth="800"
    9.       Title="EdgePage"  Background="{DynamicResource PrimaryPressedSolidColorBrush}">
    10.     <Grid>
    11.         <StackPanel VerticalAlignment="Center"
    12.                    Margin="0,0,0,40">
    13.             <Image Source="pack://application:,,,/Images/CircularMenu/4.png" Stretch="Uniform"
    14.                    Width="50"/>
    15.             <TextBlock VerticalAlignment="Center"
    16.                    HorizontalAlignment="Center"
    17.                    TextAlignment="Center"
    18.                    Foreground="White"
    19.                    Text="即将跳转至Edge浏览器"
    20.                    FontSize="{StaticResource TitleFontSize}"
    21.                    Padding="0,10">
    22.             TextBlock>
    23.         StackPanel>
    24.     Grid>
    25. Page>

    WPF开发者

    ,赞18

    参考①[3]参考②[4]

    参考资料

    [1]

    GitHub: https://github.com/WPFDevelopersOrg/WPFDevelopers

    [2]

    码云: https://github.com/WPFDevelopersOrg/WPFDevelopers

    [3]

    参考①: https://github.com/WPFDevelopersOrg/WPFDevelopers/tree/master/src/WPFDevelopers/Controls/DrawerMenu

    [4]

    参考②: https://gitee.com/WPFDevelopersOrg/WPFDevelopers/tree/master/src/WPFDevelopers/Controls/DrawerMenu

  • 相关阅读:
    jdk8排序如何防止字段为空?
    C#.Net筑基-类型系统②常见类型
    剑指offerDayN之请教大佬
    间隔连续问题
    Java框架(三)--Spring IoC容器与Bean管理(7)--基于注解配置IoC容器
    在C#中创建全局热键
    2024/6/5(页面静态化,熔断降级,降级处理,ES搜索实例,课程信息同步,认证授权,单点登录,Spring Security,OAuth2,授权模式)
    Spring 中AspectJ框架简介说明
    场景文字检测DBnet论文解读
    java线程生命周期
  • 原文地址:https://blog.csdn.net/biyusr/article/details/126049040