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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:11:11+00:00 2026-05-15T13:11:11+00:00

I have a StackPanel that I dynamically change the contents of every 5 minutes

  • 0

I have a StackPanel that I dynamically change the contents of every 5 minutes to show the user messages. These messages are displayed as TextBlock or HyperLinkButton. I’m wondering how/if I can set a style within the StackPanels style that will apply to the children.

E.g. I’ve tried

<Style x:Key="InfoBarStyle" TargetType="StackPanel">
  <Setter Property="TextElement.Foreground" Value="WhiteSmoke"/>
  <Setter Property="TextElement.FontWeight" Value="Bold"/>
</Style>

Is this possible or do I need to set the style in code behind before I add each UiElement?

  • 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-15T13:11:12+00:00Added an answer on May 15, 2026 at 1:11 pm

    You can take advantage of Implicit Styling in Silverlight 4.0 as you can in WPF. The trick is to omit the x:Key property when you define a style, and it will automatically get applied to all elements ot the TargetType within the scope of the ResourceDictionary where you define the style.

    Here’s an example:

     <StackPanel>
      <StackPanel.Resources>
        <Style TargetType="TextBlock">
          <Setter Property="TextElement.Foreground" Value="WhiteSmoke"/>
          <Setter Property="TextElement.FontWeight" Value="Bold"/>
        </Style>
      </StackPanel.Resources>
      <TextBlock Text="My Message"/>
    </StackPanel>
    

    All the TextBlock elements inside the StackPanel will now have that style applied however they get added to it.

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

Sidebar

Related Questions

I have a StackPanel that I dynamically hide/show items from, and I would like
I have a StackPanel of Image objects that are created and added dynamically. How
Say I have a StackPanel that gets dynamically filled with copy, changing the Y
I have some code that dynamically add button to StackPanel. I want to do
I have a StackPanel that contains child StackPanels (added in code behind). Parent StackPanel
I have a Stackpanel and want that the items automatically set their sizes regarding
I have a button inside of a stackpanel that has to be pressed twice
I have a stackpanel with some usercontrols that are added or removed during runtime.
I have a StackPanel in my WinRT C# Metro app that I want to
I have a StackPanel inside of a ScrollViewer. I have a slider that does

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.