How do I access the contents in a resource dictionary using C#?
For example, here is my code in XAML:
<system:String x:Key="NewGroup">New Group Name</system:String>
And I want to access it here in C#:
private void OnAddGroup(object sender, ExecutedRoutedEventArgs e)
{
BooksGroupInfo group = new BooksGroupInfo();
group.GroupName = "New Group" + TheTabControl.Items.Count;
TabItem tab = AddGroup(group);
_currentLibrary.addGroup(group);
_currentLibrary.CurrentGroup = group;
}
Instead of typing "New Group" in C#, I would like to replace that and have access in the resource dictionary in XAML. So the command will automatically get the Name that is in the resource dictionary.
I ve tried a couple of solutions like:
(System.String)this.FindResource("NewGroup");
Application.Current.Resources[typeof(System.String)];
and so on... but they do not seem to work.
I am doing a Localization using locbaml and it doesn t parse the Text/Name on C# (or I don t know how to) and that was the only solution I thought was possible.