开发者

Why won't embedded image display?

开发者 https://www.devze.com 2023-04-07 06:55 出处:网络
I am developing a Silverlight class library that contains several templated controls.One of these controls displays an image that is \"embedded\" in the class library.However, when I display the contr

I am developing a Silverlight class library that contains several templated controls. One of these controls displays an image that is "embedded" in the class library. However, when I display the control in an application, the image does not appear.

Here is how I have the image defined in the ControlTemplate for the custom control:

<Style TargetType="local:MyControl">
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="local:MyControl">
        <Border Background="DarkGray"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                >
          <StackPanel Orientation="Vertical"
                      >
            <StackPanel Orientation="Horizontal">
              <Image Height="102"
                     Margin="0,0,6,6"
                     Source="/Company.Product.Silverlight;component/Images/Logo.png"
                     VerticalAlignment="Top"
                     Width="145"
                     />
              <StackPanel Orientation="Vertical">
                <TextBlock Height="23"
                           HorizontalAlignment="Left"
                           Text="{TemplateBinding Text1}"
                           TextWrapping="Wrap"
                           VerticalAlignment="Top"
                           Width="169"
                           />
                <TextBlock Height="56"
                           HorizontalAlignment="Left"
                           Text="{TemplateBinding Text2}"
                           TextWrapping="Wrap"
                           VerticalAlignment="Top"
                           Width="169"
                           />
                <TextBlock Height="23"
                           HorizontalAlignment="Left"
                           Text="{TemplateBinding Text3}"
                           TextWrapping="Wrap"
                           VerticalAlignment="Top"
                           Width="169"
                           />
              </StackPanel>
            </StackPanel>
            <TextBlock H开发者_运维百科eight="64"
                       HorizontalAlignment="Left"
                       Margin="0,6,0,0"
                       Text="{TemplateBinding Text4}"
                       TextWrapping="Wrap"
                       VerticalAlignment="Top"
                       Width="326"
                       />
            <TextBlock Height="20"
                       HorizontalAlignment="Left"
                       Margin="0,6,0,0"
                       Text="{TemplateBinding Text5}"
                       TextWrapping="Wrap"
                       VerticalAlignment="Top"
                       Width="326"
                       />
          </StackPanel>
        </Border>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

The Build Action for the image file is set to Resource.

The only other thing to note is that the default namespace for the project is "Company.Product" (no .Silverlight suffix) because the majority of the code is linked from the .NET class library of that name. The assembly name is "Company.Product.Silverlight".

Any ideas why the image would not be displayed?

UPDATE

I've updated the code above to show the complete template.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号