views:

184

answers:

1

Hi, I am developing a WPF application, and I have created a user control called ViewIconUC. This control lives in an assembly (MyControlAssemblyUI). I can instantiate the control in a ZAML page within this control, and I get no errors (I even attached the dugger to Blend to check), and I can see the button background I set in the control, but the icon file I assign to my control does not show up. I am using the control in another assembly (MyAssembly). When I load this assembly's project into Blend, get the same behavior. However, when I actually run the application, the icon shows up just like it is supposed to. So it seems to be a problem with Blend. Any suggestions for how to get something to show up in Blend?

The XAML for the control is:

<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>

Here is the instantiation in a XAML page in the MyControlAssemblyUI assembly:

  <Grid>
      <MyControlAssemblyUI:ViewIconUC
         x:Name="m_TestToolBtn"
         IconFile="/Resources/Images/MyAppIcon32x32.png" />
  </Grid>

My instantiation in the actual app (MyAssembly) looks like this:

<MyControlAssemblyUI:ViewIconUC
  x:Name="m_SelectToolBtn"
  IconFile="/Resources/Images/SelectTool-32.png" />

I won't attach the code-behind unless someone requests it.

A: 

The problem was that the IconFile string in the client had a leading slash. I changed it to the following and everything works.

<MyControlAssemblyUI:ViewIconUC
  x:Name="m_SelectToolBtn"
  IconFile="Resources/Images/SelectTool-32.png" />
Brian Stewart