【发布时间】:2014-11-06 18:33:58
【问题描述】:
我有一个静态资源:
<x:Double x:Key="dOffset">9.6</x:Double>
我想将此资源分配给样式中的Margin.Left 属性。
我试过这个:
<Style x:Key="HomeButtonTextContainer" TargetType="StackPanel">
<Setter Property="Margin">
<Setter.Value>
<Binding Path="Thickness">
<Binding.Source>
<local:CustomThickness Left="{StaticResource dOffset}" Top="0" Bottom="0" Right="0" />
</Binding.Source>
</Binding>
</Setter.Value>
</Setter>
</Style>
但它不起作用。 我不能像下面这样将厚度声明为资源,编译器会抱怨它。
<Thickness x:Key="dOffset" Left="9.6" Right="0" Left="0" Top="0"></Thickness>
我不能从厚度类派生,所以我必须制作一个自定义的厚度来构建厚度(CustomThickness 类)
我该如何解决这个问题?
【问题讨论】:
标签: c# windows xaml mobile windows-phone-8.1