【发布时间】:2009-08-14 16:53:13
【问题描述】:
我有以下 WPF 应用程序
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="Window1" Height="300" Width="300">
<Grid>
<TabControl>
<TabItem Header="Test1">
<local:ImageView />
</TabItem>
<TabItem Header="Test2">
<local:ImageView />
</TabItem>
<TabItem Header="Test3">
<local:ImageView />
</TabItem>
</TabControl>
</Grid>
</Window>
ImageView 是一个 UserControl 定义为
<UserControl x:Class="ImageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Grid>
<Image Source="pack://application:,,,/Resources/icon.png" Width="15" Height="15" />
</Grid>
</UserControl>
当我在 TabItems 之间切换时,有时图像显示,有时不显示。为什么会这样?
【问题讨论】:
标签: wpf image xaml user-controls