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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:09:59+00:00 2026-05-28T14:09:59+00:00

i have 2 textblocks in my form. something like this: <TextBlock Name=applicationname Text={binding applicationname?}/>

  • 0

i have 2 textblocks in my form.
something like this:

<TextBlock Name="applicationname" Text="{binding applicationname?}"/>
<TextBlock Name="applicationname" Text="{binding settings.stringVersionNumber}"/>

i would like to set the first textblock content to display the application name automatically and the other one to display a string saved in the application setting ..

should i be changing the values using a “wpf code-behind” or could i just bind the textblocks directly in the xaml ?

  • 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-28T14:09:59+00:00Added an answer on May 28, 2026 at 2:09 pm

    You can data bind to static properties, including the application settings, directly in XAML:

    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:l="clr-namespace:WpfApplication1"
            xmlns:p="clr-namespace:WpfApplication1.Properties"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <StackPanel>
                <TextBlock Text="{Binding Source={x:Static l:MainWindow.AssemblyTitle}}"/>
                <TextBlock Text="{Binding Source={x:Static p:Settings.Default}, Path=VersionNumber}"/>
            </StackPanel>
        </Grid>
    </Window>
    

    …where WpfApplication1 is your namespace, and VersionNumber is a string defined in the application settings.

    To get the assembly title, we’ll need some code-behind in the MainWindow class:

    public static string AssemblyTitle
    {
        get 
        {
            return Assembly.GetExecutingAssembly()
                           .GetCustomAttributes(typeof(AssemblyTitleAttribute), false)
                           .Cast<AssemblyTitleAttribute>()
                           .Select(a => a.Title)
                           .FirstOrDefault();
        }
    }
    

    P.S. You can’t assign the same name to two elements.

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

Sidebar

Related Questions

We have two textBlocks like this: (we used .NET FW 3.0) <TextBlock Grid.Column=0 Name=tabName
I have TextBlock in my main form. I set the Text property to different
I have the following XAML: <TextBlock Text={Binding ElementName=EditListBox, Path=SelectedItems.Count} Margin=0,0,5,0/> <TextBlock Text=items selected> <TextBlock.Style>
I have a WPF form that contains a DataGrid. This DataGrid is editable. One
My typical form with Grid look like this in XAML: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width=Auto></ColumnDefinition>
In a WPF form, I have the following TextBlock. When I move my mouse
I have a flowdocument in WPF that looks like this: <FlowDocument xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml> <Paragraph
In my application, I have defined the following style for TextBlocks. <Style TargetType={x:Type TextBlock}>
I have a WPF form with a DataGrid. This DG contains a DataGridTemplateColumn that
I have a simple class like this: public class myClass { public List<string> innerList;

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.