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

  • SEARCH
  • Home
  • 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 6545913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:38:40+00:00 2026-05-25T11:38:40+00:00

this is a two part question that probbably have a similar answer. I want

  • 0

this is a two part question that probbably have a similar answer.

I want to create in a resource dictionary a style for a label that contains first an image and then the text. The text, as a TextBlock has it’s own style (had no problems there). Here is what I have

Label Style:

<Style x:Key="LabelStyle" TargetType="Label">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Label">
                <TextBlock Style="{StaticResource TextBlockStyle}">
                </TextBlock>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

TextBlockStyle:

<Style x:Key="TextBlockStyle" TargetType="{x:Type TextBlock}">
    <Setter Property="Margin" Value="25 0 0 2.5"/>
    <Setter Property="Width" Value="Auto"/>
    <Setter Property="HorizontalAlignment" Value="Left"/>
    <Style.Triggers>
        <Trigger Property="IsMouseOver" Value="True">
            <Setter Property="TextDecorations" Value="Underline"/>
            <Setter Property="Foreground" Value="Blue"/>
            <Setter Property="Cursor" Value="Hand"/>
        </Trigger>
    </Style.Triggers>
</Style>

Now my problem is when I add a new label to my Control (ex: Window) and specify the text (ex: Create), no text is shown.Something like:

<Label Style="{StaticResource LabelStyle}">Create</Label>

The text Create does not show, however if I put in my LabelStyle->TextBlock->text it shows, but it’s no good since I want to change it for different labels. Is there a way to bind my Label text to my (Inside Style) TextBlock.Text???

My other question is the same, but for images, and Image.Source.

Thanks 🙂

EDIT:

This is what I have now with H.B. answer implemented

    <Style x:Key="LabelStyle" TargetType="Label">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Label">
                <Grid>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="/Resources/Create.png" />
                        <TextBlock Style="{StaticResource TextBlockStyle}" Text="{TemplateBinding Content}"/>
                    </StackPanel>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Note that this is in the Resource Dictionary. For the TextBlock it works great. But for the image it’s a different story. I want the same as the ‘Text=”{TemplateBinding Content}’ but for the Image.Source and set it’s path in my control when I add the label. Probabbly since it’s multiple content I’ll have to write more code than I’d like, but I’ll settle for the easiest, cleanest answer.

H.B. thanks again and as for the hyperlink, this is still in development, it’s not going to be in anyway a hyperlink, just some custom menu button with some animation so it’s not so boring for the user 😛

  • 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. Editorial Team
    Editorial Team
    2026-05-25T11:38:40+00:00Added an answer on May 25, 2026 at 11:38 am

    Your Label.Template no longer links the Content property of the Label (which you set to "Create") to any internal part. To fix this you can for example bind the TextBlock.Text like this:

    <ControlTemplate TargetType="Label">
        <TextBlock Style="{StaticResource TextBlockStyle}"
                   Text="{TemplateBinding Content}"/>
    </ControlTemplate>
    

    (I just noticed that you make the Label look like a hyperlink, you do realize that there already is a class for that, right?)

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

Sidebar

Related Questions

This is a two part question. I have a class that gets all processes
This is a two part question. I'm needing to restrict a rails site that
This is a two part question, but first some background information: I have a
This is a two-part question: What applied style takes priority: a -webkit-transition rule in
This is a two-part question: I want to calculate (say) 5 business days ahead
This is a two part question. A dumb technical query and a broader query
This is a two part question. Is it possible to take advantage of xVal
This is a two-part question: First, I am interested to know what the best
This is a two-part question. I'm using jQuery for a project and wanting to
This is actually a two part question. First,does the HttpContext.Current correspond to the current

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.