How to change the value of the "Title" in WPF

0

Someone has modified the value of the title in WPF , I want to show a value in this space.

Title="text" + key

This is the one I currently have, I would like to be able to concatenate them with another variable that I have in a [key] of App.config

I appreciate your comments.

    
asked by Brian Velez 10.12.2018 в 17:18
source

2 answers

0

Used from the codebehind

public Principal()
        {
            InitializeComponent();
            this.Title = "..."; //Aquí va el texto que quieres en la ventana
        }

And from XAML you remove the Title tag

    
answered by 10.12.2018 / 19:54
source
0

To access the App.Config you have to use the Settings object, in your case you should do the following:

First go to the PROJECT menu of Visual Studio - > Properties of (your project) , then when you enter you go to Settings and there you add the keys that you want to have available in your App.Config, I recommend at user level.

The App.Config would look something like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="TuProyecto.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <userSettings>
      <OpenForiver.Properties.Settings>
            <setting name="ClaveQueQuieroUsar" serializeAs="String">
                <value>False</value>
            </setting>
        </OpenForiver.Properties.Settings>
    </userSettings>
</configuration>

And in the code you call it like this:

this.Title = "text" + Settings.Default["ClaveQueQuieroUsar"];

And that's it, that's it.

    
answered by 10.12.2018 в 21:14