wpf 地铁圈按钮背景
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17764537/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Metro Circle Button Background
提问by Altamash Shaikh
I am using Buttonwith MetroCircleButtonStylewith MetroUIin WPF. How can I change the background of this Button?
我使用Button与MetroCircleButtonStyle用MetroUI在WPF。我怎样才能改变这个背景Button?
Code:
代码:
<Button Background="Green"
Name="button2"
Style="{DynamicResource MetroCircleButtonStyle}"
Width="50" Height="50" />
Currently the button look like this but i want the one on the right:
目前按钮看起来像这样,但我想要右边的按钮:


回答by Viv
If you get the Git-Sourcefor MahApps.Metro, It has a few demo targets that show you the normal usage of almost all their controls.
如果你得到的Git-来源为MahApps.Metro,它有告诉你几乎所有的控件的正常使用几个演示目标。
In MetroDemotarget under MainWindow.xamltheir usage of MetroCircleButtonStylelooks like:
在MetroDemo目标下MainWindow.xaml他们的用法MetroCircleButtonStyle看起来像:
<Button Width="55"
Height="55"
VerticalAlignment="Top"
Style="{DynamicResource MetroCircleButtonStyle}">
<Rectangle Width="20"
Height="20">
<Rectangle.Fill>
<VisualBrush Stretch="Fill"
Visual="{StaticResource appbar_city}" />
</Rectangle.Fill>
</Rectangle>
</Button>
In your case, you'd prolly want the "appbar_add" resource
在您的情况下,您可能会想要“appbar_add”资源
<Button Width="55"
Height="55"
VerticalAlignment="Top"
Style="{DynamicResource MetroCircleButtonStyle}">
<Rectangle Width="20"
Height="20">
<Rectangle.Fill>
<VisualBrush Stretch="Fill"
Visual="{StaticResource appbar_add}" />
</Rectangle.Fill>
</Rectangle>
</Button>
Note you need to add the ResourceDictionarycontaining the Canvas's for this. It can also be got from NuGet Packages (MahApps.Metro.Resources).
请注意,您需要为此添加ResourceDictionary包含 的Canvas。它也可以从 NuGet 包 ( MahApps.Metro.Resources) 中获得。
Concept is pretty much apply the Canvaspath of your choosing(which you get quite a few of as listed in the docs) as the VisualBrushand you should be sorted.
概念几乎适用于Canvas您选择的路径(您会得到很多,如文档中所列),VisualBrush并且您应该进行排序。

