Tech Off Thread

1 post

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

problems using resources in wpf-winfx

Back to Forum: Tech Off
  • User profile image

    i am using resources in stringresources.xaml

    ResourceDictionary xmlns="">"


    sys:String x:Key="StringOne">This is the first string</sys:String>

    and made changes to application file as:

    <Application x:Class="locRes1.MyApp"xmlns="">"



    <ResourceDictionary><ResourceDictionary.MergedDictionaries><ResourceDictionary Source="StringResources.xaml" /></ResourceDictionary.MergedDictionaries>




    and written following code to retreive the resource:

    button1 = new Button();
    button1.Style = style1;
    String str1 = (String)Application.Current.FindResource("StringOne");
    button1.Content = str1;
    button1.Height = 60;
    button1.Width = 250;

    its working fine, but problem is if i try to add resources to "StringResources.xaml" throgh:

    ResourceDictionary rd=new ResourceDictionary();
    "str", "abc"); Application.Current.Resources.MergedDictionaries.Add(rd);

    m not able to write or add resources into it. 

    please guide
    how to add resource to an existing xaml file programatically

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.