整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:

WPF 按钮添加 UAC 盾牌图标

WPF 按钮添加 UAC 盾牌图标

本文经原作者授权以原创方式二次分享,欢迎转载、分享。

WPF 按钮添加 UAC 盾牌图标

作者: zhaotianff - 赵嘉

原文链接[1]:https://www.cnblogs.com/zhaotianff/p/17662237.html

上一篇[2]文章中,介绍了如何获取系统Shell的图标。在C#中调用SHGetStockIconInfo即可获取获取图标

1)定义SHGetStockIconInfo函数用到的数据结构

public enum SHSTOCKICONID : uint
{
/// <summary>Document of a type with no associated application.</summary>
SIID_DOCNOASSOC = 0,
/// <summary>Document of a type with an associated application.</summary>
SIID_DOCASSOC = 1,
/// <summary>Generic application with no custom icon.</summary>
SIID_APPLICATION = 2,
/// <summary>Folder (generic, unspecified state).</summary>
SIID_FOLDER = 3,
/// <summary>Folder (open).</summary>
SIID_FOLDEROPEN = 4,
/// <summary>5.25-inch disk drive.</summary>
SIID_DRIVE525 = 5,
/// <summary>3.5-inch disk drive.</summary>
SIID_DRIVE35 = 6,
/// <summary>Removable drive.</summary>
SIID_DRIVEREMOVE = 7,
/// <summary>Fixed drive (hard disk).</summary>
SIID_DRIVEFIXED = 8,
/// <summary>Network drive (connected).</summary>
SIID_DRIVENET = 9,
/// <summary>Network drive (disconnected).</summary>
SIID_DRIVENETDISABLED = 10,
/// <summary>CD drive.</summary>
SIID_DRIVECD = 11,
/// <summary>RAM disk drive.</summary>
SIID_DRIVERAM = 12,
/// <summary>The entire network.</summary>
SIID_WORLD = 13,
/// <summary>A computer on the network.</summary>
SIID_SERVER = 15,
/// <summary>A local printer or print destination.</summary>
SIID_PRINTER = 16,
/// <summary>The Network virtual folder (FOLDERID_NetworkFolder/CSIDL_NETWORK).</summary>
SIID_MYNETWORK = 17,
/// <summary>The Search feature.</summary>
SIID_FIND = 22,
/// <summary>The Help and Support feature.</summary>
SIID_HELP = 23,
/// <summary>Overlay for a shared item.</summary>
SIID_SHARE = 28,
/// <summary>Overlay for a shortcut.</summary>
SIID_LINK = 29,
/// <summary>Overlay for items that are expected to be slow to access.</summary>
SIID_SLOWFILE = 30,
/// <summary>The Recycle Bin (empty).</summary>
SIID_RECYCLER = 31,
/// <summary>The Recycle Bin (not empty).</summary>
SIID_RECYCLERFULL = 32,
/// <summary>Audio CD media.</summary>
SIID_MEDIACDAUDIO = 40,
/// <summary>Security lock.</summary>
SIID_LOCK = 47,
/// <summary>A virtual folder that contains the results of a search.</summary>
SIID_AUTOLIST = 49,
/// <summary>A network printer.</summary>
SIID_PRINTERNET = 50,
/// <summary>A server shared on a network.</summary>
SIID_SERVERSHARE = 51,
/// <summary>A local fax printer.</summary>
SIID_PRINTERFAX = 52,
/// <summary>A network fax printer.</summary>
SIID_PRINTERFAXNET = 53,
/// <summary>A file that receives the output of a Print to file operation.</summary>
SIID_PRINTERFILE = 54,
/// <summary>A category that results from a Stack by command to organize the contents of a folder.</summary>
SIID_STACK = 55,
/// <summary>Super Video CD (SVCD) media.</summary>
SIID_MEDIASVCD = 56,
/// <summary>A folder that contains only subfolders as child items.</summary>
SIID_STUFFEDFOLDER = 57,
/// <summary>Unknown drive type.</summary>
SIID_DRIVEUNKNOWN = 58,
/// <summary>DVD drive.</summary>
SIID_DRIVEDVD = 59,
/// <summary>DVD media.</summary>
SIID_MEDIADVD = 60,
/// <summary>DVD-RAM media.</summary>
SIID_MEDIADVDRAM = 61,
/// <summary>DVD-RW media.</summary>
SIID_MEDIADVDRW = 62,
/// <summary>DVD-R media.</summary>
SIID_MEDIADVDR = 63,
/// <summary>DVD-ROM media.</summary>
SIID_MEDIADVDROM = 64,
/// <summary>CD+ (enhanced audio CD) media.</summary>
SIID_MEDIACDAUDIOPLUS = 65,
/// <summary>CD-RW media.</summary>
SIID_MEDIACDRW = 66,
/// <summary>CD-R media.</summary>
SIID_MEDIACDR = 67,
/// <summary>A writable CD in the process of being burned.</summary>
SIID_MEDIACDBURN = 68,
/// <summary>Blank writable CD media.</summary>
SIID_MEDIABLANKCD = 69,
/// <summary>CD-ROM media.</summary>
SIID_MEDIACDROM = 70,
/// <summary>An audio file.</summary>
SIID_AUDIOFILES = 71,
/// <summary>An image file.</summary>
SIID_IMAGEFILES = 72,
/// <summary>A video file.</summary>
SIID_VIDEOFILES = 73,
/// <summary>A mixed file.</summary>
SIID_MIXEDFILES = 74,
/// <summary>Folder back.</summary>
SIID_FOLDERBACK = 75,
/// <summary>Folder front.</summary>
SIID_FOLDERFRONT = 76,
/// <summary>Security shield. Use for UAC prompts only.</summary>
SIID_SHIELD = 77,
/// <summary>Warning.</summary>
SIID_WARNING = 78,
/// <summary>Informational.</summary>
SIID_INFO = 79,
/// <summary>Error.</summary>
SIID_ERROR = 80,
/// <summary>Key.</summary>
SIID_KEY = 81,
/// <summary>Software.</summary>
SIID_SOFTWARE = 82,
/// <summary>A UI item, such as a button, that issues a rename command.</summary>
SIID_RENAME = 83,
/// <summary>A UI item, such as a button, that issues a delete command.</summary>
SIID_DELETE = 84,
/// <summary>Audio DVD media.</summary>
SIID_MEDIAAUDIODVD = 85,
/// <summary>Movie DVD media.</summary>
SIID_MEDIAMOVIEDVD = 86,
/// <summary>Enhanced CD media.</summary>
SIID_MEDIAENHANCEDCD = 87,
/// <summary>Enhanced DVD media.</summary>
SIID_MEDIAENHANCEDDVD = 88,
/// <summary>High definition DVD media in the HD DVD format.</summary>
SIID_MEDIAHDDVD = 89,
/// <summary>High definition DVD media in the Blu-ray Disc™ format.</summary>
SIID_MEDIABLURAY = 90,
/// <summary>Video CD (VCD) media.</summary>
SIID_MEDIAVCD = 91,
/// <summary>DVD+R media.</summary>
SIID_MEDIADVDPLUSR = 92,
/// <summary>DVD+RW media.</summary>
SIID_MEDIADVDPLUSRW = 93,
/// <summary>A desktop computer.</summary>
SIID_DESKTOPPC = 94,
/// <summary>A mobile computer (laptop).</summary>
SIID_MOBILEPC = 95,
/// <summary>The User Accounts Control Panel item.</summary>
SIID_USERS = 96,
/// <summary>Smart media.</summary>
SIID_MEDIASMARTMEDIA = 97,
/// <summary>CompactFlash media.</summary>
SIID_MEDIACOMPACTFLASH = 98,
/// <summary>A cell phone.</summary>
SIID_DEVICECELLPHONE = 99,
/// <summary>A digital camera.</summary>
SIID_DEVICECAMERA = 100,
/// <summary>A digital video camera.</summary>
SIID_DEVICEVIDEOCAMERA = 101,
/// <summary>An audio player.</summary>
SIID_DEVICEAUDIOPLAYER = 102,
/// <summary>Connect to network.</summary>
SIID_NETWORKCONNECT = 103,
/// <summary>The Network and Internet Control Panel item.</summary>
SIID_INTERNET = 104,
/// <summary>A compressed file with a .zip file name extension.</summary>
SIID_ZIPFILE = 105,
/// <summary>The Additional Options Control Panel item.</summary>
SIID_SETTINGS = 106,
/// <summary>High definition DVD drive (any type - HD DVD-ROM, HD DVD-R, HD-DVD-RAM) that uses the HD DVD format.</summary>
/// <remarks>Windows Vista with SP1 and later.</remarks>
SIID_DRIVEHDDVD = 132,
/// <summary>High definition DVD drive (any type - BD-ROM, BD-R, BD-RE) that uses the Blu-ray Disc format.</summary>
/// <remarks>Windows Vista with SP1 and later.</remarks>
SIID_DRIVEBD = 133,
/// <summary>High definition DVD-ROM media in the HD DVD-ROM format.</summary>
/// <remarks>Windows Vista with SP1 and later.</remarks>
SIID_MEDIAHDDVDROM = 134,
/// <summary>High definition DVD-R media in the HD DVD-R format.</summary>
/// <remarks>Windows Vista with SP1 and later.</remarks>
SIID_MEDIAHDDVDR = 135,
/// <summary>High definition DVD-RAM media in the HD DVD-RAM format.</summary>
/// <remarks>Windows Vista with SP1 and later.</remarks>
SIID_MEDIAHDDVDRAM = 136,
/// <summary>High definition DVD-ROM media in the Blu-ray Disc BD-ROM format.</summary>
/// <remarks>Windows Vista with SP1 and later.</remarks>
SIID_MEDIABDROM = 137,
/// <summary>High definition write-once media in the Blu-ray Disc BD-R format.</summary>
/// <remarks>Windows Vista with SP1 and later.</remarks>
SIID_MEDIABDR = 138,
/// <summary>High definition read/write media in the Blu-ray Disc BD-RE format.</summary>
/// <remarks>Windows Vista with SP1 and later.</remarks>
SIID_MEDIABDRE = 139,
/// <summary>A cluster disk array.</summary>
/// <remarks>Windows Vista with SP1 and later.</remarks>
SIID_CLUSTEREDDRIVE = 140,
/// <summary>The highest valid value in the enumeration.</summary>
/// <remarks>Values over 160 are Windows 7-only icons.</remarks>
SIID_MAX_ICONS = 175
}

[Flags]
public enum SHGSI : uint
{
/// <summary>The szPath and iIcon members of the SHSTOCKICONINFO structure receive the path and icon index of the requested icon, in a format suitable for passing to the ExtractIcon function. The numerical value of this flag is zero, so you always get the icon location regardless of other flags.</summary>
SHGSI_ICONLOCATION = 0,
/// <summary>The hIcon member of the SHSTOCKICONINFO structure receives a handle to the specified icon.</summary>
SHGSI_ICON = 0x000000100,
/// <summary>The iSysImageImage member of the SHSTOCKICONINFO structure receives the index of the specified icon in the system imagelist.</summary>
SHGSI_SYSICONINDEX = 0x000004000,
/// <summary>Modifies the SHGSI_ICON value by causing the function to add the link overlay to the file's icon.</summary>
SHGSI_LINKOVERLAY = 0x000008000,
/// <summary>Modifies the SHGSI_ICON value by causing the function to blend the icon with the system highlight color.</summary>
SHGSI_SELECTED = 0x000010000,
/// <summary>Modifies the SHGSI_ICON value by causing the function to retrieve the large version of the icon, as specified by the SM_CXICON and SM_CYICON system metrics.</summary>
SHGSI_LARGEICON = 0x000000000,
/// <summary>Modifies the SHGSI_ICON value by causing the function to retrieve the small version of the icon, as specified by the SM_CXSMICON and SM_CYSMICON system metrics.</summary>
SHGSI_SMALLICON = 0x000000001,
/// <summary>Modifies the SHGSI_LARGEICON or SHGSI_SMALLICON values by causing the function to retrieve the Shell-sized icons rather than the sizes specified by the system metrics.</summary>
SHGSI_SHELLICONSIZE = 0x000000004
}

[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SHSTOCKICONINFO
{
public UInt32 cbSize;
public IntPtr hIcon;
public Int32 iSysIconIndex;
public Int32 iIcon;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = UACIcon.MAX_PATH)]
public string szPath;
}

说明:SHSTOCKICONID这里实际只需要定义SIID_SHIELD这一个值就行了,我这里全部贴出来了,以后需要用到的时候可以直接到这里复制了。

2)定义UACIcon的类,在这个类里封装获取UAC图标的方法

public class UACIcon
{
public const int MAX_PATH = 260;

[DllImport("Shell32.dll", SetLastError = false)]
public static extern Int32 SHGetStockIconInfo(SHSTOCKICONID siid, SHGSI uFlags, ref SHSTOCKICONINFO psii);

[DllImport("user32.dll", SetLastError = true)]
static extern bool DestroyIcon(IntPtr hIcon);

public static BitmapSource GetUACIcon()
{
BitmapSource shieldSource = ;

SHSTOCKICONINFO sii = new SHSTOCKICONINFO();
sii.cbSize = (UInt32)Marshal.SizeOf(typeof(SHSTOCKICONINFO));

Marshal.ThrowExceptionForHR(SHGetStockIconInfo(SHSTOCKICONID.SIID_SHIELD,
SHGSI.SHGSI_ICON | SHGSI.SHGSI_LARGEICON,
ref sii));

shieldSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
sii.hIcon,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());

DestroyIcon(sii.hIcon);
return shieldSource;
}
}

上面的代码中包含了从句柄创建WPF ImageSource的代码,如果对这一块不了解的话,可以参考[3]

3)界面XAML如下:

<Grid>
<Button Width="74" Height="28">
<Button.Content>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="32"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>

<Image Stretch="Uniform" x:Name="img_Icon" Width="18" Height="18" HorizontalAlignment="Right"/>
<Label Content="确认" Grid.Column="1" HorizontalAlignment="Left"/>
</Grid>
</Button.Content>
</Button>
</Grid>

4)加载图标

public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.img_Icon.Source = UACIcon.GetUACIcon();
}
}

运行效果:

参考资料

[1]

原文链接: https://www.cnblogs.com/zhaotianff/p/17662237.html

[2]

上一篇: https://www.cnblogs.com/zhaotianff/p/17662167.html

[3]

参考: https://learn.microsoft.com/en-us/dotnet/api/system.windows.interop.imaging.createbitmapsourcefromhicon?view=windowsdesktop-7.0

信公众号:Dotnet9,网站:Dotnet9,问题或建议:请网站留言, 如果对您有所帮助:欢迎赞赏。

.NET CORE(C#) WPF亚克力窗体

阅读导航

  1. 本文背景
  2. 代码实现
  3. 本文参考
  4. 源码

1. 本文背景

本文介绍使用FluentWPF控件库实现亚克力效果的窗体。



2. 代码实现

使用 .Net Core 3.1 创建名为 “AcrylicWindow” 的WPF模板项目,添加三个Nuget库:MaterialDesignThemes、MaterialDesignColors和FluentWPF,其中亚克力效果是由FluentWPF控件库实现的。

以下为三个库具体版本:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="FluentWPF" version="0.4.0" targetFramework="net461" />
  <package id="MaterialDesignColors" version="1.1.2" targetFramework="net461" />
  <package id="MaterialDesignThemes" version="2.4.1.1101" targetFramework="net461" />
</packages>

解决方案主要文件目录组织结构:

  • AcrylicWindowApp.xamlMainWindow.xamlMainWIndow.xaml.cs

2.1 引入样式

文件【App.xaml】,在StartupUri中设置启动的视图【MainWindow.xaml】,并在【Application.Resources】节点增加MaterialDesignThemes和FluentWPF控件库的样式文件:

<Application x:Class="AcrylicWindow.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <!--  FluentWPF Controls  -->
                <ResourceDictionary Source="pack://application:,,,/FluentWPF;component/Styles/Controls.xaml" />

                <!-- Material Design Controls-->
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

2.2 演示窗体布局

文件【MainWindow.xaml】,引入MaterialDesignThemes和FluentWPF控件库的命名空间,源码如下:

<Window x:Class="AcrylicWindow.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"
        xmlns:fw="clr-namespace:SourceChord.FluentWPF;assembly=FluentWPF"
        mc:Ignorable="d"
        fw:AcrylicWindow.Enabled="True" fw:AcrylicWindow.AcrylicWindowStyle="None"
        MouseDown="Window_MouseDown" FontSize="15" Height="600" Width="1080" WindowStyle="None" AllowsTransparency="True" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="350"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Grid fw:PointerTracker.Enabled="True" Background="#01FFFFFF">
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Button Foreground="Black" Background="{x:Null}" BorderBrush="{x:Null}">
                        <materialDesign:PackIcon Kind="ArrowLeft"/>
                    </Button>
                    <TextBlock Text="Settings" FontSize="12" Margin="10" VerticalAlignment="Center"/>
                </StackPanel>
                <ListViewItem Padding="0">
                    <StackPanel Orientation="Horizontal">
                        <materialDesign:PackIcon Kind="Home" Margin="15"/>
                        <TextBlock Text="Home" VerticalAlignment="Center"/>
                    </StackPanel>
                </ListViewItem>
                <TextBlock Text="System" Margin="15" FontWeight="DemiBold"/>
                <ListView FontSize="15">
                    <ListViewItem Padding="1">
                        <StackPanel Orientation="Horizontal">
                            <materialDesign:PackIcon Kind="Monitor" Margin="15"/>
                            <TextBlock Text="Video" VerticalAlignment="Center"/>
                        </StackPanel>
                    </ListViewItem>
                    <ListViewItem Padding="1">
                        <StackPanel Orientation="Horizontal">
                            <materialDesign:PackIcon Kind="Headphones" Margin="15"/>
                            <TextBlock Text="Audio" VerticalAlignment="Center"/>
                        </StackPanel>
                    </ListViewItem>
                    <ListViewItem Padding="1">
                        <StackPanel Orientation="Horizontal">
                            <materialDesign:PackIcon Kind="MessageOutline" Margin="15"/>
                            <TextBlock Text="Notifications" VerticalAlignment="Center"/>
                        </StackPanel>
                    </ListViewItem>
                    <ListViewItem Padding="1">
                        <StackPanel Orientation="Horizontal">
                            <materialDesign:PackIcon Kind="BatteryOutline" Margin="15"/>
                            <TextBlock Text="Battery" VerticalAlignment="Center"/>
                        </StackPanel>
                    </ListViewItem>
                </ListView>
            </StackPanel>
        </Grid>
        <Grid Grid.Column="1" Background="White">

        </Grid>
    </Grid>
</Window>

关键点说一下:

  1. 作者源码中隐藏标题栏使用的【fw:AcrylicWindow.ShowTitleBar="False"】,站长使用 .NET CORE 3.1创建的项目提示该属性不存在,遂尝试敲打出【fw:AcrylicWindow.AcrylicWindowStyle="None"】属性替代,效果一样的;
  2. fw:AcrylicWindow.Enabled 属性是是否启用亚克力效果的开关,设置为True,效果见上面演示动画;设置为False,效果图如下:
  3. 演示窗体分为左右两部分,左侧设置Grid背景色“#01FFFFFF”,带有透明度才能看出亚克力效果,右侧Grid背景色设置为白色,方便左右对比。

后台代码【MainWindow.xaml.cs】实现鼠标左键拖动窗体功能:

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

3.本文参考

  1. 视频一:C# WPF Design UI: Transparent/Acrylic Window,配套源码:AcrylicWindow。

4.源码

文中代码已经全部给出,可直接Copy代码,按解决方案目录组织代码文件即可运行,另附原作者视频及源码【见3.本文参考】、站长成功编译的Demo(点击下载->AcrylicWindow)。

除非注明,文章均由 Dotnet9 整理发布,欢迎转载。转载请注明本文地址:https://dotnet9.com/7372.html

时间如流水,只能流去不流回!

点击【阅读原文】,本站还有更多技术类文章等着您哦,此刻顺便为我点个“再看”可好?

天有个想法想验证一下,但是感觉项目组web前台,后台这样开发,再联调效率有点低。

因此,想回归到原始的windows窗口程序,简单直接。

一直都很怀念当年的delphi,开发速度,尤其是开发界面速度不要太快!

delphi没落了后,开始用VS,Visual studio,不是现在前端开发用的vs code。

下载了第三方的demo后,发现vs2022中,无法将一个按钮等控件拖动到窗体上,这不扯吗,找原因没找到。

vs2022卸载了,装vs2015,又发现安装不是,老是找不到包,以前可不这样,一路next就安装下去了。难不成。。。

又回到vs2022,通过网络安装,安装上来,再打开,居然可以了。。。以前按钮,控件都是灰的,无法拖动上去。

都是界面控件可视化设计操作,怎么有点不一样呢,没有以前丝滑了。

一看,程序文件是XAML文件,打开一看,能看明白,是xml格式的控件描述。

直接用winforms多好,简单(不粗暴)。

既然第一次遇到,那就彻底搞明白。

什么是 WPF

WPF(Windows Presentation Foundation)是由微软开发的桌面应用程序框架,用于创建现代化、高度交互和具有视觉吸引力的用户界面。它是 .NET Framework 的一部分,提供了一种基于 XAML(Extensible Application Markup Language)语言的声明性编程模型,可以很容易地创建动态、灵活的用户界面,并且可以与其他 .NET 技术无缝集成。WPF 还具有强大的数据绑定和可重用性,使开发人员可以更快地构建和维护应用程序。WPF 也支持硬件加速和高分辨率显示,为用户带来更好的体验。

WPF 和 Winform 的区别

WPF(Windows Presentation Foundation)和 WinForms(Windows Forms)都是用于创建 Windows 桌面应用程序的框架,但它们有一些重要的区别:

  1. 编程模型:WPF 是基于 XAML 的声明性编程模型,它可以很容易地创建动态、灵活的用户界面,支持动画和高级视觉效果。而 WinForms 则是基于传统的命令式编程模型,需要在代码中手动设置每个控件的属性和事件处理程序。
  2. 数据绑定:WPF 有一个强大的数据绑定系统,可以将 UI 元素和数据源相互绑定,使应用程序更容易管理和更新数据。WinForms 也支持数据绑定,但不如 WPF 灵活。
  3. 可重用性:WPF 支持样式和模板,使 UI 元素可以轻松地重用和自定义,这大大简化了应用程序的开发和维护。WinForms 则需要手动创建每个 UI 元素,不太容易重用。
  4. 矢量图形和分辨率:WPF 使用矢量图形,可在高分辨率屏幕上呈现清晰的图像,而 WinForms 使用像素图形,可能在高分辨率屏幕上显示模糊或失真。

什么是XAML

Extensible Application Markup Language (Extensible Application Markup Language, XAML) 是一种声明性语言。 具体来讲,XAML 可初始化对象和设置对象的属性,使用一种可显示多个对象间分层关系的语言结构,还使用了一种支持类型扩展的支持类型约定。

使用 WPF 时首先遇到的事情之一是 XAML。XAML 代表可扩展应用程序标记语言,一种基于 XML 的简单的声明性语言,是微软用于描述 GUI 的 XML 变种。在之前的 GUI 框架如 WinForms 中,GUI 是用相同语言创建,例如 C# 或 VB.NET ,并且通常由设计者来维护。但是,通过 XAML,微软使用了另一种方式。非常类似HTML,你现在能轻松编写你的GUI。

什么是UWP

通用 Windows 平台 (UWP),可以生成适用于任何 Windows 设备(电脑、Xbox One、HoloLens 等等)的应用,然后将这些应用发布到 Store。