Solved

How can a WPF app. modify its own XAML?

Posted on 2011-02-12
2
421 Views
Last Modified: 2012-05-11
I am new to XAML and WPF, and am wondering if the GUI can have controls that allow the user to modify the way the dialog (or form) displays?  For example, by changing between a StackPanel and a DockPanel, it may look very different. How can I allow the user to change from one to the other, then render that change in the user's view?  XAML is interpreted, right?

So how can I give the user that power and havde it be real time, and not require them to have Visual Studio?

Curious...

newbieweb
0
Comment
Question by:newbieweb
2 Comments
 
LVL 10

Accepted Solution

by:
P1ST0LPETE earned 500 total points
ID: 34881330
What you would want to do is have a main container in your XAML that acts the container for your "form area".
Something as simple as a grid:

   <Grid name="GridForm">

Then in your code behind you can dynamically create other panels/content and add them to your form container.
Like this:

TextBox textbox = new TextBox();
textbox.Name = "textbox1";

DockPanel dockpanel = new DockPanel();
dockpanel.Children.Add(textbox);

GridForm.Children.Clear(); //removes previous content
GridForm.Children.Add(dockpanel); //adds new content
0
 

Author Closing Comment

by:newbieweb
ID: 34881500
I got my mind stuck on changing the XAML. But changing the page via the code behind is the logical way.

Thanks!

newbieweb
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question