Cupanther Posted January 15, 2022 Share Posted January 15, 2022 I have a value that is used multiple times in a theme that can change based on the installation need. Is there a way to define a static "configuration" variable at the beginning of the xaml file so that that value would not have to be changed throughout the rest of the code? Quote Link to comment Share on other sites More sharing options...
C-Beats Posted January 17, 2022 Share Posted January 17, 2022 Yeah, what you're wanting to utilize is called a "Resource". To define them add the following block where you typically put your root element(s). The Root elements then go under this block. <UserControl.Resources> </UserControl.Resources> Any item in that block needs a x:Key defined (string) and then when you make a binding you just bind to StaticResource of the same name you put in the key. Wall2GamesView.xaml uses this functionality if you want to look at an example. Quote Link to comment Share on other sites More sharing options...
Cupanther Posted January 17, 2022 Author Share Posted January 17, 2022 Thank you very much for your input. Not exactly what I was looking for, but it got my close and going in the right direction and ultimately led to me figuring it out. I am very new to xaml and this helped. I was trying to set a static value for a string that would be part of another string which complicated the issue for me. A few google searches I learned how to bind the static string you helped me create into string format that I needed. Thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.