问题描述
让我首先开始解释我的XAML体验很少。
Let me first start explaining that I have minimal XAML experience.
我有一个带有两个按钮的按钮contentpresenters(这可能吗?),一个用于文本,另一个用于图像。我如何绑定数据,以便显示所选图像。就像内容演示者显示您填写的文本行一样,Blend中的内容框
。
I've got a button with two contentpresenters (is this possible?), one for text and the other for an image. how can i data bind it so it will show the selected image. Just like the content presenter shows the line of text you fill in the content-box in Blend.
这是到目前为止的xaml:
This is the xaml so far:
< ContentPresenter x:Name =" contentPresenter_icon" ContentTemplate =" {TemplateBinding ContentTemplate}" Content = " how to" Margin =" 10,84,46,9" d:LayoutOverrides =" HorizontalAlignment">
< ContentPresenter.DataContext>
< BitmapImage />
< / ContentPresenter .DataContext>&
< / ContentPresenter>
<ContentPresenter x:Name="contentPresenter_icon" ContentTemplate="{TemplateBinding ContentTemplate}" Content="how to" Margin="10,84,46,9" d:LayoutOverrides="HorizontalAlignment">
<ContentPresenter.DataContext>
<BitmapImage/>
</ContentPresenter.DataContext>
</ContentPresenter>
非常感谢帮助。
推荐答案
<Button>
<Grid>
<Image Source="myimage.png"/>
<TextBlock Text="The Text"/>
</Grid>
</Button>
这篇关于将图像数据绑定到内容呈现器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!