Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change button style in Universal Windows Platform

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)

The simple button

the button when my mouse is over

like image 487
Andrei Paciurca Avatar asked Oct 03 '15 07:10

Andrei Paciurca


1 Answers

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: Edit your style

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.

like image 119
Matthias Herrmann Avatar answered Sep 20 '22 11:09

Matthias Herrmann