Jump to content
LaunchBox Community Forums

Can you define a static variable in a xaml theme file?


Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...