Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 82745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:39:54+00:00 2026-05-10T21:39:54+00:00

I have a style for an items control that binds to an image in

  • 0

I have a style for an items control that binds to an image in the target, it only appears if the target also binds to the image and I have no idea why.. can anyone shed any light on it for me?

A simplified version of my style:

<Style x:Key='testStyle' TargetType='ItemsControl'>     <Setter Property='Control.Template'>         <Setter.Value>             <ControlTemplate>                 <DockPanel HorizontalAlignment='Stretch' VerticalAlignment='Stretch' Width='Auto' Height='Auto' LastChildFill='True'>                         <Grid>                             <Grid.RowDefinitions>                                 <RowDefinition Height='32'/>                                 <RowDefinition Height='*'/>                             </Grid.RowDefinitions>                             <Grid Grid.Row='0' DockPanel.Dock='Top' MinHeight='25' SnapsToDevicePixels='True'>                                 <StackPanel Orientation='Horizontal'>                                     <Image Margin='10,0,10,0' VerticalAlignment='Stretch' Height='24' Width='24'  Source='{Binding Path=HeaderImage}' />                                     <TextBlock FontFamily='Tahoma' VerticalAlignment='Center' Text='{Binding Path=HeaderInfo}' />                                 </StackPanel>                                 <Line VerticalAlignment='Bottom' Stretch='Fill'/>                             </Grid>                             <ItemsPresenter Grid.Row='1'/>                         </Grid>                     </DockPanel>             </ControlTemplate>         </Setter.Value>     </Setter> </Style> 

My User Control:

<UserControl x:Class='StartPageView' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' > <ItemsControl Style='{DynamicResource testStyle}'>     <Grid HorizontalAlignment='Stretch' >         <StackPanel>         <GroupBox Header='Information'  Margin='0,0,0,10' >             <Label Margin='10,10,10,110'>some useful information, dynamically updated</Label>         </GroupBox>         <GroupBox Header='Available actions' Margin='0,10,0,10'>             <StackPanel>                 <Label Margin='10,10,10,10'>action 1</Label>                 <Label Margin='10,10,10,10'>action 2</Label>                 <Label Margin='10,10,10,10'>action 3</Label>                     <!--<Image Width='0' Height='0' Source='{Binding HeaderImage}'/>-->                 </StackPanel>         </GroupBox>         </StackPanel>     </Grid> </ItemsControl> 

And my model code (set as the data context for my user control)

internal class StartPageViewPresentationModel : IStartPageViewPresentationModel {     public StartPageViewPresentationModel(IStartPageView view)     {         HeaderImage = new BitmapImage(new Uri(@'Images/home_16.png', UriKind.Relative)) { CacheOption = BitmapCacheOption.Default };          HeaderInfo = 'Start Page';          View = view;         View.Model = this;     }      public BitmapImage HeaderImage { get; set; }      public string HeaderInfo { get; set; }      public IStartPageView View { get; set; } } 

If I un-comment the tag in the user control then the image is displayed both in the control and the template area, if I comment it it doesn’t appear in either. The text binding from the template works fine

I am perplexed..

thanks

Trevor

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:39:55+00:00Added an answer on May 10, 2026 at 9:39 pm

    Couple of suggestions:

    1. Have you tried an absolute URI for the image?
    2. HeaderImage can be of type ImageSource rather than the more restrictive BitmapImage.

    I suspect what’s happening is the UserControl is working because the path is relative and correct based on the location of the UserControl. The image is therefore cached and works from the template.

    However, when you comment that out the image is resolved from the location of the Style, which may not be correct?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listbox where the items contain checkboxes: <ListBox Style={StaticResource CheckBoxListStyle} Name=EditListBox> <ListBox.ItemTemplate>
If I have a style defined .style1 { width: 140px; } can I reference
How can I make a style have all of the properties of the style
I have 50+ kiosk style computers that I want to be able to get
I have a ListBox control in WPF which contains items of variable height (predominantly
We have several wizard style form applications on our website where we capture information
I have the following style in an external CSS file called first.css table {
I have a table style page with rows. Each row has a checkbox. I
I have a div container and have defined its style as follows: div#tbl-container {
In .NET 3.0, most controls have a flat style. Apparently, the date picker doesn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.