0
我有這樣的風格:綁定到附加屬性在控件模板 - Silverlight的
<Style x:Key="ButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<StackPanel>
<Image Source="{Binding Path=local:AttachedProperties.Image}" Stretch="None" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Top"/>
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</StackPanel>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
的問題是,綁定不爲按鈕工作:
<Button HorizontalAlignment="Center" Style="{StaticResource ButtonStyle}" VerticalAlignment="Center" Content="Button" local:AttachedProperties.Image="../Images/UserChart.png" Grid.RowSpan="2"/>
我做錯了什麼?
哪一個不工作?風格或附屬物(或兩者)?如果附加屬性不起作用,您應該爲其發佈代碼。 – Bryant 2009-11-05 18:17:12