【发布时间】:2014-01-24 15:39:32
【问题描述】:
将 WPF 用于 Windows 应用商店应用:
我正在寻找一种可能性,将我的 Path 对象的形状作为按钮的外观。
Path path = new Path();
Button btn = new Button();
btn.Style = path.Style; // searching for something like this
编辑: 我用这样的 Button.Content 尝试过,但也失败了:
<Button>
<Button.Content>
<Path>
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="0,0">
<ArcSegment Point="200,0"
IsLargeArc="False"
RotationAngle="180"
Size="200,200"
SweepDirection="Clockwise"
/>
<LineSegment Point="0,0"/>
....Leaving all the Closing Tags
这不应该给我一个半圆形的按钮吗?在 VisualStudio 中,我仍然得到矩形按钮。
【问题讨论】:
-
你能详细写下你需要什么吗?
Path到按钮,是在Button.Content还是在Button模板中?显示您的 XAML。 -
第一,没有
WPF for Windows Store Apps这样的东西。您一定在谈论不是 WPF 的 WinRT XAML。第二,不要在程序代码中创建或操作 UI 元素。这就是 XAML 的用途。
标签: wpf button path styles windows-store-apps