Windows phone 7 如何在Expression Blend 4中从一个模板生成具有不同背景的多个按钮
我用“makeintocontrol../button”命令从矩形中创建了一个简单的按钮模板。现在,我需要从该模板几个按钮,但每个按钮必须有不同的背景图像。我曾尝试在Blend4中这样做,但当我更改按钮背景时,按钮保留为模板背景(或无,以模板中设置的为准),忽略我为该特定按钮设置的图像。 按钮模板:Windows phone 7 如何在Expression Blend 4中从一个模板生成具有不同背景的多个按钮,windows-phone-7,expression-blend,Windows Phone 7,Expression Blend,我用“makeintocontrol../button”命令从矩形中创建了一个简单的按钮模板。现在,我需要从该模板几个按钮,但每个按钮必须有不同的背景图像。我曾尝试在Blend4中这样做,但当我更改按钮背景时,按钮保留为模板背景(或无,以模板中设置的为准),忽略我为该特定按钮设置的图像。 按钮模板: btnMenu (No brush) -rectangle (No brush) -[ContentPresenter] (some text) 我很感激你的建议 风格: <
btnMenu (No brush)
-rectangle (No brush)
-[ContentPresenter] (some text)
我很感激你的建议
风格:
<Style x:Key="btnStyleMenuHome" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid x:Name="btnMenu" Width="90" Height="70" Margin="0" VerticalAlignment="Center" HorizontalAlignment="Center">
<Grid.Background>
<ImageBrush Stretch="None"/>
</Grid.Background>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver"/>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill).(TileBrush.Stretch)" Storyboard.TargetName="rectangle">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Stretch>Uniform</Stretch>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Rectangle x:Name="rectangle" RadiusY="5" RadiusX="5" StrokeThickness="0" Width="90" Height="70" VerticalAlignment="Center" HorizontalAlignment="Center">
<Rectangle.Fill>
<ImageBrush Stretch="None" ImageSource="images/someImage.png"/>
</Rectangle.Fill>
</Rectangle>
<ContentPresenter VerticalAlignment="Bottom" Margin="7,0" d:LayoutOverrides="Width" Height="25" HorizontalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>
<ImageBrush Stretch="None"/>
</Setter.Value>
</Setter>
</Style>
统一的
看看模板样式:btnMenu(无画笔)-矩形(无画笔)-[ContentPresenter](一些文本)至于第二个问题,我找不到在哪里设置绑定(是用于按钮还是用于样式?)