"Mahapps.metro" using how to add a WPF form icon

Source: Internet
Author: User
Introduction

With a period of time Mahapps.metro, the feeling is still very useful, but in the setting of the form icon when there is a problem, the following describes the problems encountered and how to solve. content problem

Mahapps.metro gives instructions on how to add an icon:

In the same way, add Resources/icons.xaml first,

Add <resourcedictionary source= "/resources/icons.xaml"/> in the App.xaml file as shown in the figure:

But there's a problem in the back, because it's not familiar to XAML, and you don't know where to add it.

<Rectangle>
        <Rectangle.Fill>
            <visualbrush visual= "{StaticResource appbar_add}"/>
        </Rectangle.Fill>
    </Rectangle>

Just started to add it to the

But there is a problem, prompting the characteristics of the wrong name, and later looked up how to add the form icon, see a question and answer: http://stackoverflow.com/questions/17508333/ Setting-window-icon-with-a-static-resource, just mentioned the question, and gave the answer. Solve

Add the following:

<Controls:MetroWindow.IconTemplate>
        <DataTemplate>
            <grid width= "{TemplateBinding Width}"
                 height= "{TemplateBinding Height}"
                 Margin= "4"
                 background= "Transparent"
                 renderoptions.edgemode= "aliased
                 " Renderoptions.bitmapscalingmode= "highquality" >
                <Rectangle>
                    <Rectangle.Fill>
                        < VisualBrush visual= "{StaticResource appbar_home}"/>
                    </Rectangle.Fill>
                </Rectangle>
            </Grid>
        </DataTemplate>
    </Controls:MetroWindow.IconTemplate>

The final effect is as follows, I added a home icon:

Summary

Finally to everyone to share a demo, more detailed, hope can help everyone.

Https://github.com/MahApps/MahApps.Metro.Resources

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.