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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:07:50+00:00 2026-06-07T01:07:50+00:00

I want to dynamically change TextBlock text in my Class. XAML-Code : <TextBlock Name=Footer_text

  • 0

I want to dynamically change TextBlock text in my Class.

XAML-Code:

<TextBlock Name="Footer_text"  Text=""/>

C#:

string footerMainMenuText = "Setting";
Binding  set = new Binding("");
set.Mode = BindingMode.OneWay;
set.Source = footerMainMenuText;
Footer_text.DataContext = footerMainMenuText;
Footer_text.SetBinding(TextBlock.TextProperty, set);

I checked last line, and the Footer_text.Text is set correctly. ( Footer_text.Text="Setting"), but TextBlock in my application doesnt show “Setting”. What is the problem here?

  • 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-07T01:07:52+00:00Added an answer on June 7, 2026 at 1:07 am

    If you are binding – why not just do it in XAML instead? Looking at your code it’s kind of pointless – you might as well just go

    Footer_text.Text = "Setting";
    

    You should ideally do it in XAML or at least provide something for it to bind to

    <TextBlock Text="{Binding SomeProperty}" />
    

    I’m not sure why you would bind a ‘string’ on it’s own to anything…do you have an object which you need to bind to the text property?

    Also using

    Binding("")
    

    What does that do? A blank path? Not sure what the binding target would be there… have you tried

    Binding()
    

    instead?

    Edit:

    Also the reason why your binding is not updating the control, is probably because you haven’t bound to an object which implements INotifyPropertyChanged or a similar interface. The controls need to know when values have changed, so I’d imagine that binding to ‘string’ isn’t giving the TextBlock the proper notification when it changes

    Edit 2:

    Here is a quick example of binding working:

    My window class Window.cs:

    <Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
        <Grid>
            <StackPanel>
            <TextBlock x:Name="txtName" Text="{Binding Name}"></TextBlock>
                <Button Click="Button_Click">Click me 1</Button>
                <Button Click="Button_Click_1">Click me 2</Button>
            </StackPanel>
        </Grid>
    </Window>
    

    The code behind in Window.xaml.cs

    public partial class MainWindow : Window
    {
        SomeObjectClass obj = new SomeObjectClass();
        public MainWindow()
        {
            InitializeComponent();
    
            txtName.DataContext = obj;
        }
    
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            obj.Name = "Hello World";
        }
    
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            obj.Name = "Goobye World";
        }
    }
    

    The object to bind to (with INotifyPropertyChanged)

    class SomeObjectClass : INotifyPropertyChanged
    {
        private string _name = "hello";
        public string Name
        {
            get
            {
                return _name;
            }
            set
            {
                _name = value;
                OnPropertyChanged("Name");
            }
        }
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        public void OnPropertyChanged(string PropertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
        }
    }
    

    Clicking the buttons changes SomeObject.Name, but it updates the textbox.

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

Sidebar

Related Questions

I want to dynamically change content , by following code. localStorage.removeItem(some key); but current
I want to make a downloading uilabel whose label text will change dynamically when
I have a canvas.DrawText. I want to use gestures to dynamically change the text
I want to dynamically change display name from within the application. Is there a
I want to dynamically change the data-href for the fb comments plugin below based
I'm working on a project where we want to dynamically change the IP address
I have a label in my form. I want this label to dynamically change
I want to change the color of the title bar dynamically, ie: someone clicks
I have problem with dynamically created image (JavaScript). I want to change the innerHTML
I want to dynamically create instance method of child class through class method of

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.