绑定到ControlTemplate中的附加属性 - Silverlight

时间:2009-11-05 15:04:34

标签: silverlight attached-properties

我有这种风格:

 <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"/>

我做错了什么?

1 个答案:

答案 0 :(得分:1)

听起来,这是一个Silverlight问题。有关此帖子的更多信息:

http://forums.silverlight.net/forums/p/102737/299184.aspx