1
我正在开发一个WPF应用程序,并创建了一个名为ViewIconUC的用户控件。该控件位于程序集中(MyControlAssemblyUI)。我可以在此控件中的ZAML页面中实例化控件,并且我没有任何错误(我甚至将dugger附加到Blend中进行检查),并且可以看到我在控件中设置的按钮背景,但是我分配的图标文件我的控制不显示。我正在使用另一个程序集中的控件(MyAssembly)。当我将这个程序集的项目载入Blend时,获得相同的行为。但是,当我真正运行应用程序时,图标就像它应该显示的一样。所以它似乎是Blend的一个问题。有关如何在Blend中显示某些内容的任何建议?Blend不在用户控件中渲染图像
的XAML的控制是:
<UserControl
x:Class="MyStuff.MyControlAssemblyUI.ViewIconUC"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="m_ViewIconUC"
Height="36" Width="42"
>
<UserControl.Resources>
<Style TargetType="Button">
<Setter Property="Background" Value="#40FFFFFF"/>
</Style>
<Style TargetType="Image">
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
</Style>
</UserControl.Resources>
<Button x:Name="m_ViewIconUC_Button">
<Image
x:Name="m_ViewIconUC_Image"
Source="{Binding ElementName=m_ViewIconUC, Path=IconFile}"
/>
</Button>
</UserControl>
这里是在MyControlAssemblyUI装配在XAML页面的实例:
<Grid>
<MyControlAssemblyUI:ViewIconUC
x:Name="m_TestToolBtn"
IconFile="/Resources/Images/MyAppIcon32x32.png" />
</Grid>
我在实际的应用实例(MyAssembly程序)看起来像这样:
<MyControlAssemblyUI:ViewIconUC
x:Name="m_SelectToolBtn"
IconFile="/Resources/Images/SelectTool-32.png" />
我不会附加代码隐藏,除非有人请求它。