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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:07:31+00:00 2026-06-18T10:07:31+00:00

<ListBox x:Name=noteListBox VerticalAlignment=Stretch HorizontalAlignment=Stretch Foreground=#FF329BD6 Margin=0,24,0,85> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock x:Name=noteTitle FontSize=40 Text={Binding Titolo}

  • 0
<ListBox x:Name="noteListBox" 
                 VerticalAlignment="Stretch" 
                 HorizontalAlignment="Stretch" Foreground="#FF329BD6" Margin="0,24,0,85">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock x:Name="noteTitle"
                            FontSize="40"
                            Text="{Binding Titolo}"
                            Tag="{Binding FileName}"
                            Foreground="#FF45B1EE" Tap="apriNota" Margin="5,0,0,0" />
                        <TextBlock x:Name="noteDateCreated"
                            Text="{Binding DateCreated}"
                            Margin="10,0,0,10" Foreground="#FF60ADD8" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

I need to dynamically change the Foreground color of those two TextBlocks inside the StackPanel. The problem is that they don’t seem to be accessible from my C# code, suppose because they’re in that StackPanel.

So basically this is what I need to do:

noteTitle.Foreground = new SolidColorBrush(Color.FromArgb(255, 50, 155, 214));

But I can’t even find noteTitle in my C# code… How can I fix this?

Thank you!

  • 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-06-18T10:07:32+00:00Added an answer on June 18, 2026 at 10:07 am

    I would suggest using value converter for such purposes. I assume foreground value depends on a state of object whcih ahs proeprties FileName, DateCreated you bind to, so just use this object as converetr parameter and in converter do main calculation to decide which Foreground should be returned for this particular item.

    public class EntityToForegroundConverter : System.Windows.Data.IValueConverter
    {
        public object Convert(object value, 
                             Type targetType, 
                             object parameter, 
                             CultureInfo culture) 
        {
            var entity = value as IMyEntity;
            // TODO: determine a foreground value based on bound 
            // object proerrty values
        }
    
        public object ConvertBack(object value, 
                                  Type targetType, 
                                  object parameter, 
                                  CultureInfo culture)
        {
            return null;
        }
    }
    
    <Control.Resources>
        <src:EntityToForegroundConverter x:Key="foregroundConverter"/>
    </Control.Resources>
    
    <TextBlock 
       Foreground="{Binding Converter={StaticResource foregroundConverter}}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following listbox: <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation=Horizontal Margin=0,10,0,10> <TextBlock Foreground=Black Text={Binding name}/>
I have xaml that lookes like this <ListBox> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text={Binding Name}
I had use listbox.itemsource as my e.Result. <ListBox Height=476 HorizontalAlignment=Left Margin=11,17,0,0 Name=ListBox1 VerticalAlignment=Top Width=434
I have the following XAML: ... <ListBox Name =RoomsListBox Height=100 HorizontalAlignment=Left Margin=12,41,0,0 VerticalAlignment=Top Width=120></ListBox>
my listbox: <ListBox x:Name=listBox Grid.Row=2 FontSize=26 SelectionChanged=listBox_SelectionChanged ItemsSource={Binding SelectedSubGenre.PhotoCollection}> <ListBox.ItemTemplate> <DataTemplate> <Border BorderBrush=BurlyWood BorderThickness=1,1,1,1
<ListBox Height=434 HorizontalAlignment=Left Margin=6,238,0,0 Name=listBox1 VerticalAlignment=Top Width=432 DataContext={Binding}> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text={Binding Name}
A have listbox <ListBox> <ListBox.ItemTemplate> <DataTemplate> <DockPanel> <Button Content={Binding name_trainer} Tag={Binding idPersonTrainer} DockPanel.Dock=Top HorizontalAlignment=Center>
I have the following ListBox with an ItemTemplate <ListBox SelectionMode=Multiple ItemsSource={Binding MyItems} DisplayMemberPath=Name> <ListBox.ItemTemplate>
I have a listbox on a page: <select id=user_list name=user_list size=21 style=width:200px;> <option value=1>User
I have a loop that takes file name from a listbox, performs a system()

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.