[英]How to bind an image to a button template using Blend?
In Microsoft Expression Blend, I have the following button template: 在Microsoft Expression Blend中,我具有以下按钮模板:
<ControlTemplate x:Key="ImageBlueButton" TargetType="{x:Type Button}">
<Grid x:Name="MainGrid" Width="75" Height="50">
<Grid.RowDefinitions>
<RowDefinition Height="0.5*"/>
<RowDefinition Height="0.5*"/>
</Grid.RowDefinitions>
<ContentPresenter x:Name="TextContent" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0" Grid.Row="1" d:LayoutOverrides="Width, Height"/>
<Image x:Name="ButtonImage" Margin="0" Grid.RowSpan="1" HorizontalAlignment="Center" VerticalAlignment="Center" Source="{TemplateBinding Content}"/>
</Grid>
</ControlTemplate>
I manually edited the XAML to add the Source={TemplateBinding Content} property to the Image tag. 我手动编辑了XAML,将Source = {TemplateBinding Content}属性添加到Image标记。 My question is, how do I assign an image to a button object that's using this template inside Blend?
我的问题是,如何将图像分配给在Blend中使用此模板的按钮对象?
In Blend, I can see a Common Properties window with Content field in it, but changing it only updates the text on the button. 在Blend中,我可以看到一个Common Content窗口,其中包含Content字段,但是更改它只会更新按钮上的文本。 I'm guessing I need to use Custom Expression, to set both Text Content and Image content at the same time?
我猜我需要使用自定义表达式来同时设置文本内容和图像内容吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.