472,805 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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>

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

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


Sep 21 '07 #1
0 5637

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

Similar topics

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...
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...
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: ...
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
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...
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>...
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...
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? ...
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...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.