aceBox
aceBox

Reputation: 731

Designer code in Windows phone 7

I created a UI using XAML, in windows phone 7. I want to know if this code exists as C# code in some file and if it is so, where is the designer code, generated by the xaml?

Upvotes: 1

Views: 58

Answers (2)

Norbert Pisz
Norbert Pisz

Reputation: 3440

When you create code in XAML this code in C# doesn't exist in any file in your project. The XAML code is changed to object in compilation process. Here You have great article about this process:

Article

You can create GUI in code behind using objects like this:

var stackPanel = new StackPanel();

Upvotes: 0

Toni Petrina
Toni Petrina

Reputation: 7122

If you want to create StackPanel programmatically, you can do it by "mimicking" the XAML version.

For example, the following XAML:

<StackPanel Foreground="White"
            Margin="12,0,0,0">
</StackPanel>

can be created with the following C# code:

var stackPanel = new StackPanel();
stackPanel.Foreground = new SolidColorBrush("White");
stackPanel.Margin = new Thickness(12,0,0,0);

Without knowing what your StackPanel looks like, I cannot offer you any tipss.


I must wonder why you want to do that? XAML is generally far better to design than doing it in via code. Not to mention it is cleaner and is adaptable to MVVM which is the best solution for your application.

If you offer some more details, I can offer precise advice.

Upvotes: 2

Related Questions