【发布时间】:2016-02-03 14:26:26
【问题描述】:
我有一个按钮的自定义样式
<Style x:Key="CustomButton" TargetType="Button">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Content">
<Setter.Value>
<Grid>
<Ellipse Width="40" Height="20" Fill="Yellow"/>
<TextBlock Text="{Binding ****Bind to Content Property on button***}"/>
</Grid>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border>
<Border.Background>
<SolidColorBrush x:Name="CustomBackground"
Color="LightBlue"/>
</Border.Background>
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我的Content 属性有一个复杂的对象。 content 属性的值有一个TextBlock。是否可以将Textblock 的Text 属性绑定到Button 的Content 属性
<Button Style="{StaticResource CustomButton}"
Content="Bound to Textblock in style"/>
【问题讨论】: