【发布时间】:2011-09-14 10:41:58
【问题描述】:
使用 windows.resource 中的下一个代码块。
<Style TargetType="Button" x:Key="l1" >
<Setter Property="Button.Effect" >
<!--<Setter Property="BitmapEffect">-->
<Setter.Value>
<DropShadowEffect />
</Setter.Value>
</Setter>
<Setter Property="Content" >
<Setter.Value >
<StackPanel Orientation="Horizontal">
<Image Source="Resources\find.bmp" Stretch="Uniform" ></Image>
<TextBlock>Find</TextBlock>
</StackPanel>
</Setter.Value>
</Setter>
</Style>
它仅适用于一个按钮,但一旦我将它应用于在运行时生成的第二个按钮错误。
<Button Height="23" HorizontalAlignment="Left" Margin="322,25,0,0" Name="Button18" VerticalAlignment="Top" Width="75" Style="{StaticResource l1}" />
<Button Height="23" HorizontalAlignment="Left" Margin="586,37,0,0" Name="Button19" VerticalAlignment="Top" Width="75" Style="{StaticResource l1}" />
有解决这个问题的办法吗?
【问题讨论】:
-
你实际上得到了什么错误?
标签: wpf xaml styles stackpanel