乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      C# WPF遮罩對(duì)話框(Popup Message Overlay/ Dialog Host)

       行者花雕 2021-04-18

      時(shí)間如流水,只能流去不流回!

      點(diǎn)贊再看,養(yǎng)成習(xí)慣,這是您給我創(chuàng)作的動(dòng)力!

      本文 Dotnet9 https:// 已收錄,站長(zhǎng)樂(lè)于分享dotnet相關(guān)技術(shù),比如Winform、WPF、ASP.NET Core、Xamarin.Forms等,亦有C++桌面相關(guān)的Qt Quick和Qt Widgets等,只分享自己熟悉的、自己會(huì)的。

      閱讀導(dǎo)航:

      • 一、先看效果
      • 二、本文背景
      • 三、代碼實(shí)現(xiàn)
      • 四、文章參考
      • 五、代碼下載

      一、先看效果

      二、本文背景

      YouTube  Design com WPF 大神處習(xí)得,常用的遮罩對(duì)話框?qū)崿F(xiàn),使用的開源 C# WPF控件庫(kù) MaterialDesignInXAML ,本站曾有介紹:開源C# WPF控件庫(kù)《MaterialDesignInXAML》

      三、代碼實(shí)現(xiàn)

      3.1 添加Nuget庫(kù)

      站長(zhǎng)使用.Net Core 3.1創(chuàng)建的WPF工程,創(chuàng)建“ScreenOverlayMessage”解決方案后,需要添加兩個(gè)Nuget庫(kù):MaterialDesignThemes和MaterialDesignColors,上圖的效果是使用該控件庫(kù)實(shí)現(xiàn)的,非常強(qiáng)大。

      C# WPF抽屜效果實(shí)現(xiàn)(C# WPF Material Design UI: Navigation Drawer & PopUp Menu)

      3.2 工程結(jié)構(gòu)

      不需要截圖,只修改了兩個(gè)文件,App.xaml添加MD控件4個(gè)樣式文件,MainWindow主窗口實(shí)現(xiàn)效果。

      3.3 App.xaml引入MD控件樣式

      <Application x:Class="DropDownMenu.App"
                   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:local="clr-namespace:DropDownMenu"
                   StartupUri="MainWindow.xaml">
          <Application.Resources>
              <ResourceDictionary>
                  <ResourceDictionary.MergedDictionaries>
                      <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml"/>
                      <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml"/>
                      <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml"/>
                      <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Indigo.xaml"/>
                  </ResourceDictionary.MergedDictionaries>
              </ResourceDictionary>
          </Application.Resources>
      </Application>

      3.4 主窗體

      MainWindow.xaml,整體布局,看上圖加上下面的界面代碼,添加界面左上角logo圖標(biāo)、左側(cè)導(dǎo)航菜單等,下面即是全部代碼。

      <Window x:Class="ScreenOverlayMessage.MainWindow"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas./markup-compatibility/2006"
              xmlns:local="clr-namespace:ScreenOverlayMessage"
              mc:Ignorable="d"
              xmlns:materialDesign="http:///winfx/xaml/themes" MouseDown="Window_MouseDown"
              Title="MainWindow" Height="576" Width="1024" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" WindowStyle="None" Background="#FF423A3A">
          <Grid>
              <materialDesign:DialogHost BorderBrush="{DynamicResource MaterialDesignDivider}">
                  <materialDesign:DialogHost.DialogContent>
                      <Grid Width="300" Height="150" HorizontalAlignment="Center">
                          <StackPanel Orientation="Horizontal" Margin="15">
                              <materialDesign:PackIcon Kind="Folder" Foreground="{StaticResource PrimaryHueMidBrush}" Width="50" Height="50"/>
                              <TextBlock Foreground="Gray" Width="200" Margin="15 5" TextWrapping="Wrap">
                                  允許應(yīng)用程序訪問(wèn)您計(jì)算機(jī)上的照片、媒體和文件?
                              </TextBlock>
                          </StackPanel>
                          <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="15">
                              <Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" Style="{DynamicResource MaterialDesignFlatButton}" Margin="4" VerticalAlignment="Center">
                                  拒絕
                              </Button>
                              <Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" Style="{DynamicResource MaterialDesignFlatButton}" Margin="4" VerticalAlignment="Center">
                                  允許
                              </Button>
                          </StackPanel>
                      </Grid>
                  </materialDesign:DialogHost.DialogContent>
                  <Grid>
                      <StackPanel Width="200" HorizontalAlignment="Left" Background="#FF472076">
                          <Grid Height="150" Background="White">
                              <Image Source="https://img./logo.png"/>
                          </Grid>
                          <Button Style="{StaticResource MaterialDesignFlatButton}" Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">
                              <StackPanel Orientation="Horizontal" Height="30">
                                  <materialDesign:PackIcon Kind="PhotoAlbum" Width="20" Height="20" VerticalAlignment="Center"/>
                                  <TextBlock Text="照片" Margin="20 0" FontSize="15" VerticalAlignment="Center"/>
                              </StackPanel>
                          </Button>
                          <Button Style="{StaticResource MaterialDesignFlatButton}" Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">
                              <StackPanel Orientation="Horizontal" Height="30">
                                  <materialDesign:PackIcon Kind="Music" Width="20" Height="20" VerticalAlignment="Center"/>
                                  <TextBlock Text="音樂(lè)" Margin="20 0" FontSize="15" VerticalAlignment="Center"/>
                              </StackPanel>
                          </Button>
                      </StackPanel>
                  </Grid>
              </materialDesign:DialogHost>
          </Grid>
      </Window>

      重點(diǎn)講解:

      • materialDesign:DialogHost:設(shè)置遮罩對(duì)話框覆蓋的地方,即彈出遮罩對(duì)話框后,背后有陰影的位置。
      • materialDesign:DialogHost.DialogContent:對(duì)話框內(nèi)容,即彈出的對(duì)話框配置

      后臺(tái)有個(gè)拖動(dòng)窗體代碼:

      private void Window_MouseDown(object sender, MouseButtonEventArgs e)
      {
          DragMove();
      }

      四、文章參考

      建議直接打開大神視頻學(xué)習(xí),他的YouTube上還有很多代碼視頻哦,參考:
      參考視頻: Design com WPF: https://www./watch?v=Dwi9o3K73XM

      五、代碼下載

      文章中代碼已經(jīng)全部貼出。

      除非注明,文章均由 Dotnet9 整理發(fā)布,歡迎轉(zhuǎn)載。

      轉(zhuǎn)載請(qǐng)注明本文地址:https:///6769.html

      歡迎掃描下方二維碼關(guān)注 Dotnet9 的微信公眾號(hào),本站會(huì)及時(shí)推送最新技術(shù)文章(微信公眾號(hào)“dotnet9_com”):

       

      如有收獲,請(qǐng)大力轉(zhuǎn)發(fā),給Dotnet9贊助和支持,謝謝大家對(duì)dotnet技術(shù)的關(guān)注和支持 。

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多