【发布时间】:2018-09-13 13:37:23
【问题描述】:
我编写了以下代码以在工具提示窗口中的ListBoxItem 的内容中显示图像(一种预览效果)。但他们根本不工作。
<ListBox>
<ListBoxItem>
<Image x:Name="image" Source="image.jpg" Stretch="Uniform">
<Image.ToolTip>
<Image Source="{Binding RelativeSource={RelativeSource AncestorType=Image}, Path=Source}" />
</Image.ToolTip>
</Image>
</ListBoxItem>
<ListBox>
<ListBox>
<ListBoxItem>
<Image x:Name="image" Source="image.jpg" Stretch="Uniform">
<Image.ToolTip>
<Image Source="{Binding Source, RelativeSource={RelativeSource TemplatedParent}}" />
</Image.ToolTip>
</Image>
</ListBoxItem>
<ListBox>
<ListBox>
<ListBoxItem>
<Image x:Name="image" Source="image.jpg" Stretch="Uniform">
<Image.ToolTip>
<Image Source="{Binding}" />
</Image.ToolTip>
</Image>
</ListBoxItem>
<ListBox>
这些都不起作用。
【问题讨论】:
标签: wpf xaml data-binding templatebinding