Change button style in Universal Windows Platform(在通用 Windows 平台中更改按钮样式)
问题描述
我尝试制作一个简单的 C# UWP 应用程序,但当我的鼠标悬停在按钮上时,我不知道如何移除灰色背景.
我该怎么做?
(记住:它是适用于 Windows 10 平台的 UWP,而不是 Windows Phone 8.1 或 WPF)
请按以下步骤操作:
- 在解决方案资源管理器中单击鼠标右键并添加一个新项目ResourceDictionary"
- 复制按钮的默认样式你可以在这个网页上找到它,你需要向下滚动一点:
如果您使用 Blend for Visual Studio 有一个更简单的解决方案,您可以更快地编辑这些内容,但要保持结构并学习它,上面的解决方案是更好的解决方案.
I've tried to make a simple C# UWP application and I don't know how to remove the gray background when my mouse is over the button.
How I do that?
(remember: it's an UWP for Windows 10 platform , not Windows Phone 8.1 or WPF)
Follow these steps:
- Rightclick in the Solution Explorer and add a new item of kind "ResourceDictionary"
- Copy the Default Style of the Button you can find it on this webpage, you need to scroll down a little bit: Msdn
Then insert it in your ResourceDictionary.xaml format should look like this:
<ResourceDictionary><Style></Style></ResourceDictionary>
3. Give the Style a key like this:
<Style x:Key="MyCustomButton"></Style>
4. Go to App.xaml edit it by adding the Resource Dictionary like this:
<Application.Resources>
<ResourceDictionary Source="Resources.xaml"></ResourceDictionary>
</Application.Resources>
The Source of the ResourceDictionary is the Name of your ResourceDictionary file.
- Then add the style to your button like this:
<Button Style="{StaticResource MyCustomButton}"></Button>
- Last but not least go back to your ResourceDictionary and delete the following code lines you see in the Screenshot or comment it out like i did:
There is a more easy solution if you use Blend for Visual Studio there you can edit this stuff more quickly but to keep the structure and for learning it the solution above is the better one.
这篇关于在通用 Windows 平台中更改按钮样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在通用 Windows 平台中更改按钮样式


- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 输入按键事件处理程序 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01