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 343511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:54:16+00:00 2026-05-12T10:54:16+00:00

changing a static resource during runtine is something that sounds not possible. I have

  • 0

changing a static resource during runtine is something that sounds not possible.

I have a TextBox which displays a simple number. Then I have defined a style, which changes the Template of the TextBox to become a round TextBox:

<Style x:Key="RoundNumberDisplay" TargetType="TextBox">
        <Setter Property="Width" Value="22"/>
        <Setter Property="Height" Value="22"/>

        <Setter Property="Template">
            <Setter.Value>

                    <ControlTemplate>
                        <Border x:Name="brd1" Width="20" Height="20" CornerRadius="15">
                            <TextBlock x:Name="txt1" Foreground="#222" TextAlignment="center" Text="1" FontSize="14" FontWeight="ExtraBold" VerticalAlignment="center" />
                            <Border.Background>
                                <RadialGradientBrush GradientOrigin=".3, .3">
                                    <GradientStop Color="{StaticResource ColorBackground1}" Offset=".15"/>
                                    <GradientStop Color="{StaticResource ColorForeground1}" Offset="1"/>
                                </RadialGradientBrush>
                            </Border.Background>
                        </Border>
                    </ControlTemplate>

            </Setter.Value>
        </Setter>

    </Style>

As you can see, the displayed text is “hard-wired” in the TextBlock “txt1”. So obviously, I can’t change the number during runtime.

My question now is: What is the best way to change the displayed number? Creating a Style for each number looks a bit ineffective to me.

Thanks in advance,
Frank

  • 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-12T10:54:16+00:00Added an answer on May 12, 2026 at 10:54 am

    TemplateBinding to be able to set the value of the txt1-Text-Property from the target TextBox. Important: The target-type for the ControlTemplate must be set!

        <Style ...
    
                        <ControlTemplate **TargetType="TextBox"**>
                                ...
    
                                <TextBlock x:Name="txt1" Foreground="#222" TextAlignment="center" **Text="{TemplateBinding Text}"** FontSize="14" FontWeight="ExtraBold" VerticalAlignment="center" />
                        </ControlTemplate>
        </Style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a very simple ASP.NET web application comprising mostly static content and a
Is it a good OOP practice to have static variables to store global, changing
I know how to initialize a static member that's not an integer, but I'm
My company is considering changing continuous integration servers (I won't say which one we
I am changing a GET to a POST. Currently I have .jsp?id=a,b,c,d. When changing
i am changing my hardware which currently runs Win XP and i am wondering
I have a really basic user control with a button that has an image.
I am (very) new to WPF and I have got a question regarding that.
I have a winforms application that the users must be able to change the
I have a large program with several large DLL's that are compiled with MFC

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.