C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » WPF »

Loading Xaml runtime by xamlreader


Posted Date: 04 Nov 2009    Resource Type: Articles    Category: WPF
Author: K Hari PrasadMember Level: Gold    
Rating: 1 out of 5Points: 5



XamlReader



The set of XamlReader.Load methods parse XAML, create the appropriate .NET objects, and return an instance of the root element.


Window window = null;
using (FileStream fs =
new FileStream("MyWindow.xaml", FileMode.Open, FileAccess.Read))
{
// Get the root element, which we know is a Window
window = (Window)XamlReader.Load(fs);
}
// Grab the OK button by walking the children (with hard-coded knowledge!)
StackPanel panel = (StackPanel)window.Content;
Button okButton = (Button)panel.Children[4];


If the structure of the window is not known, we can use name of the control to
find the control like below.


Window window = null;
using (FileStream fs =
new FileStream(“MyWindow.xaml”, FileMode.Open, FileAccess.Read))
{
// Get the root element, which we know is a Window
window = (Window)XamlReader.Load(fs);
}
// Grab the OK button, knowing only its name
Button okButton = (Button)window.FindName("okButton");



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Xamlreader loading xaml runtime  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Loading and Parsing XAML at run time by using XAML Reader.
Previous Resource: Using ItemContainerStyle in ListView.
Return to Discussion Resource Index
Post New Resource
Category: WPF


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use