【发布时间】:2013-08-04 20:07:20
【问题描述】:
好的,我为 Buttons 创建了一个新样式,我想在我的应用程序中使用它。一般的想法是有 10 个正方形 Button,其中我将有一个 Image,在此下方是一个 TextBlock。
我的问题是我想为每个Button 设置我的Image.Source 和我的TextBlock.Text 不同。
我在做什么:
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="Border" CornerRadius="5" BorderThickness="1" Background="Gray" BorderBrush="Orange">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Image Margin="0,5,0,0" Grid.Row="0" Width="25" Height="25" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<TextBlock FontSize="12"/>
</Grid>
</Border>
我应该怎么做才能发挥我这样的风格?
<Button Style="{DynamicResource MenuButtons}" Text="????" x:Name="LiveB" Source="????" Click="Live_Click"/>
提前致谢。
【问题讨论】:
-
看看这个:stackoverflow.com/questions/2734825/… 你需要的都有:)
标签: c# wpf templates button binding