right now I have multiple buttons and other elements. Each of these has a x:Name and a Content.
I also have a list which has elements with the same names as the x:Name of the WPF parts.
My goal is to have a function I can call over and over again, give it the x:name of an element and it sets the value after the name in the list ( {name1, value, name2, value, name3, value ..} )to the content of the WPF element with that name.
For Example:
I have a list:
config{tree, 1, chair, 4, window, 3, dollar, 200}
<Button x:Name="chair" Content="12"/>
<Button x:Name="tree" Content="5"/>
Now I want to call a function, giving it the config{} and x:Name="chair". It should search for an element "chair" in the config now and replace the 4 after that with the 12 from the Content. Now I want to call it with the next Button ( x:Name="tree") to change the value 1 to 5;
I really don't know, how to describe that properly :(
This is the function I have right now:
public void SetConfig(List<string> config, string name)
{
config[config.IndexOf(name) + 1] = myWindow.name.Content.ToString();
}
The myWindow.NAME.Content.ToString(); part does not work, because I can not use a variable in that.
Is there any way, I can still do this ?
Thanks in advance :D