【发布时间】:2012-07-21 20:52:56
【问题描述】:
我有这个 xaml 代码,需要从 C# 代码动态设置点。
<Style x:Key="Mystyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Polygon Points="0,0 0,100 50,200" Fill="{TemplateBinding Background}"
Stroke="{TemplateBinding BorderBrush}"/>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
【问题讨论】:
-
嗯。使用 ViewModel 进行数据绑定? What have you tried?
-
@Moataz A.Mohammed 发生了什么?我的解决方案不起作用?
-
是的,我不知道为什么现在我正在尝试使用 XamlReader。因为 Windows Phone 中的 NotificationObject 类不在普通的 WPF dll 中
-
NotificationObject 在 Microsoft.Practices.Prism.dll 程序集中,您可以在普通的 WPF 应用程序中使用这个类,而不仅仅是在 Windows Phone 中。另一方面,您可以实现 interfejs INotifyPropertyChanged,一切都会好起来的。我使用了这个类,因为它是更快的解决方案。