Lloyd Powell
Lloyd Powell

Reputation: 18800

How do I express static code in XAML?

I have a control that I would like to be static, but instead of writing it in code, i would like it to be in the XAML, so that I can still design edit and play around with it in Blend.

Basically, within my class, I have the code:

public static TextBox s_notepad = new TextBox();

I've altered my code to attempt to make it easier to explain.

If anyone knows the equivalent to this in XAML, it would be fantastic if they could let me know.

Thanks,

Lloyd

Upvotes: 2

Views: 237

Answers (2)

NPayette
NPayette

Reputation: 179

XAML code works by instance you cannot declare static code into your XAML.

But you can use the x:Static keywords in order to have access to static property from other objects.

Upvotes: 3

Todd Main
Todd Main

Reputation: 29155

Yes, it would be <TextBox/> in XAML. Almost all of the objects have a direct mapping to XAML and can be found directly in the Help files under the XAML section on the page if there is a way of expressing it in XAML.

Upvotes: -1

Related Questions