Change button style in Universal Windows Platform

后端 未结 1 1632
悲哀的现实
悲哀的现实 2021-01-12 03:41

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?

(remem

相关标签:
1条回答
  • 2021-01-12 03:58

    Follow these steps:

    1. Rightclick in the Solution Explorer and add a new item of kind "ResourceDictionary"
    2. 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.

    1. Then add the style to your button like this: <Button Style="{StaticResource MyCustomButton}"></Button>
    2. 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.

    0 讨论(0)
提交回复
热议问题