473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XAMLReader for external xaml files and event handling

I have a sample XAML file:

<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Button Name="button2" Height="23" Width="300" Margin="31,37,0,0"
Click="doit">Hello World</Button>
</StackPanel>

If I compile the application normally, the XAML is converted to a .cs and
then an application is built: on clicking the button "doit" gets called if it
is code-behind or is embedded in an <x:codeblock within the XAML itself.
The problem arises when I try to load XAML files on the fly at runtime, using
StreamReader and XamlReader:-
//Load file1.xaml
StreamReader sr = new StreamReader("file1.xaml");
DependencyObject rootElement =
XamlReader.Load(sr.BaseStream) as DependencyObject;

XamlReader throws an exception with a message "Must compile XAML file that
specifies events"

This happens when the event is either code-behind or inline in an <x:code>
tag within the XAML itself.

I would really like the flexibilty of being able to generate code on the fly
without having to re-compile my application (even though I will take a hit on
performance).

Does anyone know how I can loadruntime XAML files which have event calls?

Thanks


Sep 21 '07 #1
0 5686

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Thilaka | last post by:
Hi guys, Recently i read some articles on Longhorn & XAML. & From what i learnt the future for developing UIs lies in XAML. Does this mean that I've got to learn XAML as developing UIs for web...
8
by: John Dunn | last post by:
Since currently we aren't allowed to have compiled XAML files embedded in C++ apps I'm using Markup::XamlReader::Load to dynamically load XAML files. This works perfectly fine with external files...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
6
by: moondaddy | last post by:
will CodeDom create XAML windows or just regular windows forms? If so, how to I tell it to create a xaml window instead of a windows form? thanks -- moondaddy@noemail.noemail
3
by: arunonw3 | last post by:
Please answer me 1. Is XAML maily aiming windows. Why is the controls on double click not produce the event handlers in the c# file( code behind or something ...) 2. XAML web browser...
3
by: onno.willems | last post by:
Hi, A little part of my (.NET 2.0) WinForm GUI need to be configurable by a user. The user can specify a variable number of items which should appear on a form like this: <Label<Label<ComboBox>...
6
by: star-italia | last post by:
Hi, Is it possible to include a XAML file into another XAML file? For example If i have - Window1.xaml - Window2.xaml and both have a treeview with a custom Style, can i describe the style...
1
by: DeanB | last post by:
Please excuse my ignorance here as I have not used WPF for long, but what is the statement that tells what the "local:" identifier is that allows a window event to call a function in a .cs file? ...
0
by: aagranov2007 | last post by:
I'm using XamlReader.Load to swap screens in my application. On my main canvas, I have a constructor that builds up a context menu with event handlers. The first time my app loads a screen...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.