CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Posts
    1

    WPF Control Content overwite at startup

    I am new to the world of WPF - so not sure how to do the below functionality. It will be great if someone can help me.

    I have developed an app using WPF (XAML). What I am trying to do is during the start up time of the app, I am trying to read a file (.txt and xml) and I am trying to load the content for the controls from there. Those names will overwrite the default names for the controls given in the xaml files. I am loading the default names in xaml file from a resx file.
    For example, one control is the name of the. In resx file, I stored "default user". Now every user should be able to display there name by simple adding a pre-defined tag "My_Name" and then providing there name in a .txt file. The app, on strat up, should load that string from the .txt file.
    I found out a way to do it in the code - by reading the string from the file and assiging thet Control.Content = "Name_Read_From_File" - but I am trying to do it at the strat-up time by parsing the xaml file directly - so that I can restrict the functionality in one place. Many thanks in advance...

  2. #2
    Join Date
    Jan 2006
    Location
    18° 32' N / 73° 52' E
    Posts
    416

    Re: WPF Control Content overwite at startup

    Do you want to put a "placeholder" kindof thing in the xaml?
    If this is what you want, then there is a way.

    In the xaml file, do somthing like this
    Code:
    Control.Content={Binding Content}
    and in the codebehind at start up,
    do this way: Based on the logic, show the appropriate value.
    Code:
    Control.Content="My Name";
    I hope this is what you expect.
    Last edited by MMH; April 20th, 2009 at 07:17 AM.
    Regards,
    MMH
    Rate my post if you find it usefull.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured