應用程式使用統計信息 – .NET CORE(C#) WPF界面設計

来源:https://www.cnblogs.com/Dotnet9-com/archive/2020/03/15/12497461.html
-Advertisement-
Play Games

應用程式使用統計信息 .NET CORE(C ) WPF界面設計 首發文章地址:https://dotnet9.com/10546.html 關鍵功能點 1. 抽屜式菜單 2. 圓形進度條 Demo演示: 1. 新建項目 使用 VS 2019 的 .NET Core 3.1 WPF 項目模板,創建名 ...


應用程式使用統計信息 - .NET CORE(C#) WPF界面設計

首發文章地址:https://dotnet9.com/10546.html

關鍵功能點

  1. 抽屜式菜單
  2. 圓形進度條

Demo演示:

1. 新建項目

使用 VS 2019 的 .NET Core 3.1 WPF 項目模板,創建名為 “MobileAppUsageDashboardCore” 的項目,NuGet 引入 MaterialDesign 的兩個庫 MaterialDesignThemes 和 MaterialDesignColors,整個項目工程文件如下:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MaterialDesignColors" Version="1.2.2" />
    <PackageReference Include="MaterialDesignThemes" Version="3.0.1" />
  </ItemGroup>

</Project>

2.抽屜式菜單

前面發過不少抽屜式菜單的Demo文章,套路都是一個豎直菜單隱藏在界面左邊邊界之外,左邊邊界留一個菜單按鈕,點擊該按鈕呼出豎直菜單,即達到抽屜式菜單效果。

本文介紹的抽屜式菜單也不外如是,VS設計界面見上圖,使用的MD控制項的DrawerHost.LeftDrawerContent組件,換一種方式實現,下麵是抽屜菜單佈局代碼:

<materialDesign:DrawerHost.LeftDrawerContent>
    <StackPanel Orientation="Vertical">
        <StackPanel Margin="10" VerticalAlignment="Top" Orientation="Horizontal">
            <TextBlock
                VerticalAlignment="Center"
                Margin="0,0,10,0">Dashboard</TextBlock>
            <Button Style="{StaticResource MaterialDesignFlatButton}"
                    Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
                    >
                <materialDesign:PackIcon Kind="HamburgerMenuBack"></materialDesign:PackIcon>
            </Button>
        </StackPanel>
        <StackPanel Orientation="Vertical">
            <Button Style="{StaticResource MaterialDesignFlatButton}" Click="todayBtnClicked">今天</Button>
            <Button Style="{StaticResource MaterialDesignFlatButton}" Click="weekBtnClicked">本周</Button>
            <Button Style="{StaticResource MaterialDesignFlatButton}" Click="monthBtnClicked">本月</Button>
        </StackPanel>
    </StackPanel>
</materialDesign:DrawerHost.LeftDrawerContent>

跟隨菜單隱藏的還有一個菜單關閉按鈕,見上面代碼中的第一個按鈕,點擊按鈕觸發 “DrawerHost.CloseDrawerCommand” 命令可關閉抽屜式菜單。

下麵的是窗體邊界之內的菜單按鈕,點擊則展開抽屜式菜單,觸發的命令是“DrawerHost.OpenDrawerCommand”:

<Button Style="{StaticResource MaterialDesignFlatButton}" Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        >
                            <materialDesign:PackIcon Kind="HamburgerMenu"></materialDesign:PackIcon>
                        </Button>

3.圓形進度條

使用MD控制項庫實現圓形進度條,效果如下:

圓形進度條代碼如下,使用的還是 ProgressBar 控制項,樣式使用了MD控制項庫的“MaterialDesignCircularProgressBar” 樣式,組件載入時(Loaded事件),使用了雙精度動畫:

<ProgressBar Height="100"
            Width="100"
Value="40" Foreground="#FF68E843"
        x:Name="firstProgress"
            >
    <ProgressBar.Style>
        <Style TargetType="ProgressBar" BasedOn="{StaticResource MaterialDesignCircularProgressBar}">
            <Style.Triggers>
                <EventTrigger RoutedEvent="Loaded">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetProperty="Value" From="0" To="40"
                                            Duration="0:0:0.5"></DoubleAnimation>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Style.Triggers>
        </Style>
    </ProgressBar.Style>
</ProgressBar>

4. Demo源碼

整個Demo也不難,除了上面兩個小功能單獨簡單說說外,其他的就是一般的佈局代碼了,主界面XAML代碼如下:

<Window x:Class="MobileAppUsageDashboardCore.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        TextElement.Foreground="{DynamicResource MaterialDesignBody}"
        TextElement.FontWeight="Regular"
        TextElement.FontSize="13"
        TextOptions.TextFormattingMode="Ideal"
        TextOptions.TextRenderingMode="Auto"
        Background="{DynamicResource MaterialDesignPaper}"
        FontFamily="{DynamicResource MaterialDesignFont}"
        Title="應用程式使用統計信息" Height="450" Width="800" 
        WindowStartupLocation="CenterScreen" AllowsTransparency="True" WindowStyle="None" MouseLeftButtonDown="dragME">
    <materialDesign:DrawerHost x:Name="mainDrawer">
        <materialDesign:DrawerHost.LeftDrawerContent>
            <StackPanel Orientation="Vertical">
                <StackPanel Margin="10" VerticalAlignment="Top" Orientation="Horizontal">
                    <TextBlock
                        VerticalAlignment="Center"
                        Margin="0,0,10,0">Dashboard</TextBlock>
                    <Button Style="{StaticResource MaterialDesignFlatButton}"
                            Command="{x:Static materialDesign:DrawerHost.CloseDrawerCommand}"
                            >
                        <materialDesign:PackIcon Kind="HamburgerMenuBack"></materialDesign:PackIcon>
                    </Button>
                </StackPanel>
                <StackPanel Orientation="Vertical">
                    <Button Style="{StaticResource MaterialDesignFlatButton}" Click="todayBtnClicked">今天</Button>
                    <Button Style="{StaticResource MaterialDesignFlatButton}" Click="weekBtnClicked">本周</Button>
                    <Button Style="{StaticResource MaterialDesignFlatButton}" Click="monthBtnClicked">本月</Button>
                </StackPanel>
            </StackPanel>
        </materialDesign:DrawerHost.LeftDrawerContent>
        <materialDesign:Card HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <materialDesign:Card.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="Black" Offset="1"/>
                    <GradientStop Color="#FF474747"/>
                </LinearGradientBrush>
            </materialDesign:Card.Background>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column="0" Orientation="Vertical" Margin="10">
                    <StackPanel Orientation="Horizontal">
                        <Button Style="{StaticResource MaterialDesignFlatButton}" Command="{x:Static materialDesign:DrawerHost.OpenDrawerCommand}"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        >
                            <materialDesign:PackIcon Kind="HamburgerMenu"></materialDesign:PackIcon>
                        </Button>
                        <TextBlock VerticalAlignment="Center" Text="移動應用使用儀錶板"></TextBlock>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="時間段" VerticalAlignment="Center"></TextBlock>
                        <StackPanel Orientation="Horizontal" Margin="4">
                            <RadioButton x:Name="todayRadio" Style="{StaticResource MaterialDesignTabRadioButton}"
                                         Margin="4"
                                         IsChecked="True"
                                         Content="今天"></RadioButton>
                            <RadioButton x:Name="weekRadio" Style="{StaticResource MaterialDesignTabRadioButton}"
                                         Margin="4"
                                         IsChecked="False"
                                         Content="本周"></RadioButton>
                            <RadioButton x:Name="monthRadio" Style="{StaticResource MaterialDesignTabRadioButton}"
                                         Margin="4"
                                         IsChecked="False"
                                         Content="本月"></RadioButton>
                        </StackPanel>
                    </StackPanel>
                    <UniformGrid Columns="3" Margin="0,10,0,0">
                        <materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="2*"></RowDefinition>
                                    <RowDefinition Height="*"></RowDefinition>
                                </Grid.RowDefinitions>
                                <ProgressBar Height="100"
                                         Width="100"
                                Value="40" Foreground="#FF68E843"
                                        x:Name="firstProgress"
                                         >
                                    <ProgressBar.Style>
                                        <Style TargetType="ProgressBar" BasedOn="{StaticResource MaterialDesignCircularProgressBar}">
                                            <Style.Triggers>
                                                <EventTrigger RoutedEvent="Loaded">
                                                    <BeginStoryboard>
                                                        <Storyboard>
                                                            <DoubleAnimation Storyboard.TargetProperty="Value" From="0" To="40"
                                                                         Duration="0:0:0.5"></DoubleAnimation>
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </EventTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </ProgressBar.Style>
                                </ProgressBar>
                                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="2 小時 / 5 小時"></TextBlock>
                                <TextBlock Grid.Row="1" Text="百度" HorizontalAlignment="Center" Margin="0,5,0,0"></TextBlock>
                            </Grid>
                        </materialDesign:TransitioningContent>
                        <materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn}">

                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="2*"></RowDefinition>
                                    <RowDefinition Height="*"></RowDefinition>
                                </Grid.RowDefinitions>
                                <ProgressBar Height="100"
                                         Width="100"
                                        Value="70" Foreground="#FFE84343"
                                        x:Name="secondProgress" Margin="14,-1,13,1"
                                         >
                                    <ProgressBar.Style>
                                        <Style TargetType="ProgressBar" BasedOn="{StaticResource MaterialDesignCircularProgressBar}">
                                            <Style.Triggers>
                                                <EventTrigger RoutedEvent="Loaded">
                                                    <BeginStoryboard>
                                                        <Storyboard>
                                                            <DoubleAnimation Storyboard.TargetProperty="Value" From="0" To="70"
                                                                         Duration="0:0:0.5"></DoubleAnimation>
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </EventTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </ProgressBar.Style>
                                </ProgressBar>
                                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="2 小時 / 3 小時"></TextBlock>
                                <TextBlock Grid.Row="1" Text="阿裡巴巴" HorizontalAlignment="Center" Margin="0,5,0,0"></TextBlock>
                            </Grid>
                        </materialDesign:TransitioningContent>
                        <materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn}">

                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="2*"></RowDefinition>
                                    <RowDefinition Height="*"></RowDefinition>
                                </Grid.RowDefinitions>
                                <ProgressBar Height="100"
                                         Width="100"
                                 Value="30" Foreground="#FFE8E843"
                                        x:Name="thirdProgress"
                                         >
                                    <ProgressBar.Style>
                                        <Style TargetType="ProgressBar" BasedOn="{StaticResource MaterialDesignCircularProgressBar}">
                                            <Style.Triggers>
                                                <EventTrigger RoutedEvent="Loaded">
                                                    <BeginStoryboard>
                                                        <Storyboard>
                                                            <DoubleAnimation Storyboard.TargetProperty="Value" From="0" To="30"
                                                                         Duration="0:0:0.5"></DoubleAnimation>
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </EventTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </ProgressBar.Style>
                                </ProgressBar>
                                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="1 小時 / 4 小時"></TextBlock>
                                <TextBlock Grid.Row="1" Text="騰訊" HorizontalAlignment="Center" Margin="0,5,0,0"></TextBlock>
                            </Grid>
                        </materialDesign:TransitioningContent>
                    </UniformGrid>
                    <materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn,Duration=0:0:1}">
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,80,0,0">
                            <TextBlock Text="訂閱到 " VerticalAlignment="Center"></TextBlock>
                            <materialDesign:PackIcon Kind="DotNet" Foreground="#DDFF1212" Width="100" Height="100"></materialDesign:PackIcon>
                            <TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Text="www.dotnet9.com" VerticalAlignment="Center"></TextBlock>
                        </StackPanel>
                    </materialDesign:TransitioningContent>
                </StackPanel>
                <materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect Kind=SlideInFromTop}" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <materialDesign:Card VerticalAlignment="Stretch">
                        <materialDesign:Card.Background>
                            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                <GradientStop Color="#FF09A6A6" Offset="0"/>
                                <GradientStop Color="#FF044D4D" Offset="1"/>
                            </LinearGradientBrush>
                        </materialDesign:Card.Background>
                        <Grid >
                            <Grid.RowDefinitions>
                                <RowDefinition></RowDefinition>
                                <RowDefinition></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid Grid.Row="0" Margin="5,15,5,5">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <StackPanel Grid.Column="0">
                                    <TextBlock Text="充電" HorizontalAlignment="Center"></TextBlock>
                                    <materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect Kind=FadeIn, Duration=0:0:2}">
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
                                            <TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}" Text="4" HorizontalAlignment="Center"></TextBlock>
                                            <TextBlock Text=" 次" VerticalAlignment="Center"></TextBlock>
                                        </StackPanel>
                                    </materialDesign:TransitioningContent>
                                    <TextBlock Text="最高溫度" HorizontalAlignment="Center" Margin="0,25,0,0"></TextBlock>
                                    <materialDesign:TransitioningContent 
                                        OpeningEffect="{materialDesign:TransitionEffect Kind=FadeIn, Duration=0:0:2}">

                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
                                            <TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}" Text="40" HorizontalAlignment="Center"></TextBlock>
                                            <TextBlock Text=" ℃" VerticalAlignment="Center"></TextBlock>
                                        </StackPanel>
                                    </materialDesign:TransitioningContent>
                                    <TextBlock Text="解鎖" HorizontalAlignment="Center" Margin="0,25,0,0"></TextBlock>
                                    <materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect Kind=FadeIn,Duration=0:0:2}">
                                        <TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}"  Text="75" HorizontalAlignment="Center" Margin="0,10,0,0"></TextBlock>
                                    </materialDesign:TransitioningContent>
                                </StackPanel>

                                <StackPanel Grid.Column="1">
                                    <TextBlock Text="開機" HorizontalAlignment="Center"></TextBlock>
                                    <materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect Kind=FadeIn, Duration=0:0:2}">

                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
                                            <TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}" Text="6" HorizontalAlignment="Center"></TextBlock>
                                            <TextBlock Text=" 小時" VerticalAlignment="Center"></TextBlock>
                                        </StackPanel>
                                    </materialDesign:TransitioningContent>
                                    <TextBlock Text="最後一次充電" HorizontalAlignment="Center" Margin="0,25,0,0"></TextBlock>
                                    <materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect Kind=FadeIn, Duration=0:0:2}">
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,0">
                                            <TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}" Text="4" HorizontalAlignment="Center"></TextBlock>
                                            <TextBlock Text=" 小時以前" VerticalAlignment="Center"></TextBlock>
                                        </StackPanel>
                                    </materialDesign:TransitioningContent>
                                    <TextBlock Text="通知" HorizontalAlignment="Center" Margin="0,25,0,0"></TextBlock>
                                    <materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect Kind=FadeIn,Duration=0:0:2}">
                                        <TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}"  Text="350" HorizontalAlignment="Center" Margin="0,10,0,0"></TextBlock>
                                    </materialDesign:TransitioningContent>
                                </StackPanel>
                            </Grid>
                            <Grid Grid.Row="1" Background="#FF086666">
                                <Grid.RowDefinitions>
                                    <RowDefinition></RowDefinition>
                                    <RowDefinition></RowDefinition>
                                    <RowDefinition></RowDefinition>
                                </Grid.RowDefinitions>
                                <StackPanel Orientation="Vertical" Grid.Row="0" Margin="5,15,5,5">
                                    <Grid>
                                        <TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}" Text="存儲" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
                                        <TextBlock Text="19.88 GB / 40 GB" HorizontalAlignment="Right" VerticalAlignment="Center"></TextBlock>
                                    </Grid>
                                    <ProgressBar Height="10" Value="19.88" Maximum="40" Margin="0,10,0,0" Foreground="#FF1E1E1E"></ProgressBar>
                                </StackPanel>
                                <StackPanel Orientation="Vertical" Grid.Row="1" Margin="5,15,5,5">
                                    <Grid>
                                        <TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}" 
                                                   Text="相冊" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
                                        <TextBlock Text="3 GB" HorizontalAlignment="Right" VerticalAlignment="Center"></TextBlock>
                                    </Grid>
                                    <ProgressBar Height="10" Value="3" Maximum="40" Margin="0,10,0,0" Foreground="#FF1E1E1E"></ProgressBar>
                                </StackPanel>
                                <StackPanel Orientation="Vertical" Grid.Row="2" Margin="5,15,5,5">
                                    <Grid>
                                        <TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}" Text="視頻" HorizontalAlignment="Left" VerticalAlignment="Center"></TextBlock>
                                        <TextBlock Text="4 GB" HorizontalAlignment="Right" VerticalAlignment="Center"></TextBlock>
                                    </Grid>
                                    <ProgressBar Height="10" Value="4" Maximum="40" Margin="0,10,0,0" Foreground="#FF1E1E1E"></ProgressBar>
                                </StackPanel>
                            </Grid>
                        </Grid>

                    </materialDesign:Card>
                </materialDesign:TransitioningContent>
                <!--<TextBlock Style="{DynamicResource MaterialDesignTitleTextBlock}">My First Material Design App</TextBlock>-->
                <materialDesign:TransitioningContent Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Top" OpeningEffect="{materialDesign:TransitionEffect Kind=SlideInFromTop}">
                    <TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}" Text="最常用的應用程式" Margin="0,15,0,0"></TextBlock>
                </materialDesign:TransitioningContent>
                <materialDesign:TransitioningContent 
                    Grid.Column="2"
                    OpeningEffect="{materialDesign:TransitionEffect Kind=FadeIn}" Margin="0,40,0,0">
                    <ItemsControl>
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <UniformGrid Columns="2"></UniformGrid>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <materialDesign:TransitioningContent OpeningEffectsOffset="{materialDesign:IndexedItemOffsetMultiplier 0:0:0.05}" OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn}">
                            <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="Google Chrome">
                                <materialDesign:PackIcon Kind="GoogleChrome" Height="24" Width="24" ></materialDesign:PackIcon>
                            </Button>
                        </materialDesign:TransitioningContent>
                        <materialDesign:TransitioningContent OpeningEffectsOffset="{materialDesign:IndexedItemOffsetMultiplier 0:0:0.05}" OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn}">

                            <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="YouTube">
                                <materialDesign:PackIcon Kind="Youtube" Height="24" Width="24"></materialDesign:PackIcon>
                            </Button>
                        </materialDesign:TransitioningContent>
                        <materialDesign:TransitioningContent OpeningEffectsOffset="{materialDesign:IndexedItemOffsetMultiplier 0:0:0.05}" OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn}">
                            <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="Instagram">
                                <materialDesign:PackIcon Kind="Instagram" Height="24" Width="24"></materialDesign:PackIcon>
                            </Button>
                        </materialDesign:TransitioningContent>
                        <materialDesign:TransitioningContent OpeningEffectsOffset="{materialDesign:IndexedItemOffsetMultiplier 0:0:0.05}" OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn}">
                            <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="Facebook">
                                <materialDesign:PackIcon Kind="Facebook" Height="24" Width="24"></materialDesign:PackIcon>
                            </Button>
                        </materialDesign:TransitioningContent>
                        <materialDesign:TransitioningContent OpeningEffectsOffset="{materialDesign:IndexedItemOffsetMultiplier 0:0:0.05}" OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn}">
                            <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="Twitter">
                                <materialDesign:PackIcon Kind="Twitter" Height="24" Width="24"></materialDesign:PackIcon>
                            </Button>
                        </materialDesign:TransitioningContent>
                        <materialDesign:TransitioningContent OpeningEffectsOffset="{materialDesign:IndexedItemOffsetMultiplier 0:0:0.05}" OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn}">

                            <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="YouTube Creator Studio">
                                <materialDesign:PackIcon Kind="YoutubeCreatorStudio" Height="24" Width="24"></materialDesign:PackIcon>
                            </Button>
                        </materialDesign:TransitioningContent>
                        <materialDesign:TransitioningContent OpeningEffectsOffset="{materialDesign:IndexedItemOffsetMultiplier 0:0:0.05}" OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn}">

                            <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="Adobe Reader">
                                <materialDesign:PackIcon Kind="Adobe" Height="24" Width="24"></materialDesign:PackIcon>
                            </Button>
                        </materialDesign:TransitioningContent>
                        <materialDesign:TransitioningContent OpeningEffectsOffset="{materialDesign:IndexedItemOffsetMultiplier 0:0:0.05}" OpeningEffect="{materialDesign:TransitionEffect Kind=ExpandIn}">
                            <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="Camera">
                                <materialDesign:PackIcon Kind="Camera" Height="24" Width="24"></materialDesign:PackIcon>
                            </Button>
                        </materialDesign:TransitioningContent>
                    </ItemsControl>
                </materialDesign:TransitioningContent>
            </Grid>
        </materialDesign:Card>

    </materialDesign:DrawerHost>
</Window>

5. 主界面後臺代碼

代碼不多,比較簡單,源碼如下:

using System;
using System.Windows;
using System.Windows.Input;

namespace MobileAppUsageDashboardCore
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private void todayBtnClicked(object sender, RoutedEventArgs e)
        {
            mainDrawer.IsLeftDrawerOpen = false;
            todayRadio.IsChecked = true;
            monthRadio.IsChecked = false;
            weekRadio.IsChecked = false;
        }

        private void weekBtnClicked(object sender, RoutedEventArgs e)
        {
            mainDrawer.IsLeftDrawerOpen = false;
            todayRadio.IsChecked = false;
            weekRadio.IsChecked = true;
            monthRadio.IsChecked = false;
        }

        private void monthBtnClicked(object sender, RoutedEventArgs e)
        {
            mainDrawer.IsLeftDrawerOpen = false;
            todayRadio.IsChecked = false;
            weekRadio.IsChecked = false;
            monthRadio.IsChecked = true;
        }

        private void dragME(object sender, MouseButtonEventArgs e)
        {
            try
            {
                DragMove();
            }
            catch (Exception)
            {

                //throw;
            }
        }
    }
}

3. Demo展示、源碼下載

前面演示的Demo源碼已經全部貼上。

參考視頻:WPF Dashboard UI - Material Design [Speed Design]

參考源碼:WPF-Dashboard-UI-Material-Design-Concept


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 目 錄 1. 概述... 2 2. iNeuOS平臺演示... 2 3. 設備驅動管理... 2 4. 服務驅動管理... 3 5. 雲組態自定義畫布... 4 6. 快速切換組態頁面菜單... 5 7. 自定義右鍵菜單項,顯示組態子頁面... 5 8. 工況關聯數據點... 6 9. 修改用戶密碼 ...
  • 本次是在原有ApiTemplate項目之上,增加一個用戶登錄許可權控制模塊,用於驗證ApiTemplate項目在面對一些簡單問題時,如何抽象並支持未來的擴展。用戶登錄許可權控制模塊看上去很簡單,但由於業餘時間總是有限的。所以藉助此機會實踐一次用戶敏捷開發。首先拆分模塊,本次只實現用戶登錄和登出。apit ...
  • 棄元就是使用下劃線_作為一個占位符,但不占存儲空間。 元組(ValueTuple、Tuple)使用棄元例子。 using System; namespace ConsoleApp4 { class Program { public static void Main() { // ValueTuple ...
  • 這篇文章是為了梳理自己關於委托的知識脈落,便於對委托有更清晰的認識。 本文的重點不在於,委托是什麼,怎麼定義委托,委托有什麼好處。。。這些網上知識很豐富了。 本文演示的是 委托是怎麼一步步形成並精簡代碼的 我稱之為“進化”。 這些方法也是從.net 1.0 2.0 3.0版本一步步形成的。 ...
  • WPF 項目遷移到.Net Core中時居然出了一堆問題...(很無語) 今天在使用的時候居然發現Process.Start居然打不開Url鏈接了? 報 找不到指定文件 的異常?! 一、bug重現 首先以.Net Core 3.1框架 中一個Console項目 打開百度為例: 運行然後你就會得到: ...
  • 在本文中,我將講解如何通過自定義 ,以便在中間件管道中發生錯誤時創建自定義響應,而不是提供一個“重新執行”管道的路徑。 作者:依樂祝 譯文:https://www.cnblogs.com/yilezhu/p/12497937.html 原文:https://andrewlock.net/creati ...
  • 我們先看一下執行流程圖圖中畫紅圈的部分便是HttpModule,在說創建HttpModule之前,先說一下HttpApplication對象,HttpApplication對象由Asp.net框架創建,每個請求對應一個HttpApplcation實例對象,Asp.Net框架內部維護了一個HttpAp... ...
  • 因為對C#不是特別熟悉,但是最近寫個c#的demo,需要對獲取的的json字元串進行解析,開始使用Newtonsoft.Json.Linq嘗試了以下,但是感覺操作起來比較麻煩,尤其對與JSON結構比較深的情況。可能是習慣了其它語言的方式,很想能找到類似的方法。 最終瞭解到System.Web.Scr ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...