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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:33:51+00:00 2026-06-12T01:33:51+00:00

I once had a WinForms application in which I used a static class for

  • 0

I once had a WinForms application in which I used a static class for simple string resources. In this class I had constant strings I could acces. One of those strings consisted of the value of another constant, plus its own value. Something like this:

private const string Path = @"C:\SomeFolder\";
public const string FileOne = Path + "FileOne.txt";
public const string FileTwo = Path + "FileTwo.txt";

Now I have a WPF application and I am using a ResourceDictionary, which I merged to Application scope. Everything works fine, but I want something similar like the C# code above. This is what I already have:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:System="clr-namespace:System;assembly=mscorlib">

    <System:String x:Key="Path">C:\SomeFolder\</System:String>
    <System:String x:Key="FileOne">FileOne.txt</System:String>
    <System:String x:Key="FileTwo">FileTwo.txt</System:String>

</ResourceDictionary>

Now I need something (some kind of reference to ‘Path’) that is automatically added to the two file-strings, it doesn’t need to be private like in the C# code. Does anyone know how I can achieve this?

Thanks in advance!

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

    If you want to use it i XAML, here are two ideas for you:

    Idea 1: one Binding

    In your resources, only add the Path:

    <System:String x:Key="Path">C:\SomeFolder\</System:String>
    

    And, somewhere in your XAML:

    <TextBlock Text='{Binding Source={StaticResource Path}, StringFormat={}{0}FileOne.txt}' />
    

    This will display Path+”FileOne.txt”

    (note: you can write whatever you want instead of FileOne.txt )

    You can have custom stuff using this way.

    Idea 2: One MultiBinding

    More convenient for what you are trying to do imho: you keep those three Resources you defined.

    If you want to call them somewhere so that Path + fileOne will be displayed, just use that (example with a TextBlock )

        <TextBlock >
            <TextBlock.Text>
                <MultiBinding StringFormat="{}{0}{1}">
                    <Binding Source="{StaticResource Path}" />
                    <Binding Source="{StaticResource FileOne}" />
                </MultiBinding>
            </TextBlock.Text>
        </TextBlock>
    

    That’s all you need!

    Alternatively if you don’t use those Strings in your UI, you can still use a static class. But using the XAML way is cleaner imho (all UI-related stuff should stay in XAML anyway)

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

Sidebar

Related Questions

Once I had a file, to see the contents I used cat command, say
I remember once i had temporary data used on a webpage. I used php
Once I had spent hours in debugging a simple SQL query using mysql_query() in
I once had a MySQL database table containing 25 million records, which made even
I have a server that is running Ubuntu Linux Server Edition. I once had
I once found a web site that had some 'Requires .net 1.0', 'Requires .net
I had a login page. once user successfuly logged in, they can view and
Once again, I'm at a loss with IE7 on this one. I'm making a
Hopefully I am wording/asking this right. I have a Winforms, .Net 3.5, app that
We once had an interview with a very experienced C++ developer who couldn't answer

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.