locked
Dynamic XAML RRS feed

  • Question

  • Hi,

    Have played around with the WPF/E plugin and static XAML for a while now. But what I really want to do is to generate dynamic XAML on the server with WPF and push it to the client side.

    What do I need installed for such a scenario and are there any good examples on how to generate dynamic serverside XAML for the WPF/E plugin ?

    Tim

     

    Thursday, January 25, 2007 6:59 PM

Answers

  • I don't have a good example to show you, but dynamic XAML is pretty straightforward. I have examples (that I haven't publicized yet) that show dynamic XAML in several forms:

    • Using createFromXaml to create templates on the client.  The SDK samples show this in several examples, most notably the VideoPlayer example.
    • I've created dynamic XAML as a XAML island on an ASP.NET page using simple string concatenation.
    • I've created dynamic XAML by creating a .aspx page that emitted an entire XAML document. 
    • Lastly, I've also created .ascx pages that emitted dynamic XAML. I've done this in conjuction with a XAML island on a page to create reusable XAML (e.g. a Button class).

    Several of these examples will be available in an upcoming appendix for the Chris Sells/Ian Griffiths (O'Reilly) WPF book.

    Thursday, January 25, 2007 7:17 PM

All replies

  • I don't have a good example to show you, but dynamic XAML is pretty straightforward. I have examples (that I haven't publicized yet) that show dynamic XAML in several forms:

    • Using createFromXaml to create templates on the client.  The SDK samples show this in several examples, most notably the VideoPlayer example.
    • I've created dynamic XAML as a XAML island on an ASP.NET page using simple string concatenation.
    • I've created dynamic XAML by creating a .aspx page that emitted an entire XAML document. 
    • Lastly, I've also created .ascx pages that emitted dynamic XAML. I've done this in conjuction with a XAML island on a page to create reusable XAML (e.g. a Button class).

    Several of these examples will be available in an upcoming appendix for the Chris Sells/Ian Griffiths (O'Reilly) WPF book.

    Thursday, January 25, 2007 7:17 PM
  • Hi Shawn and thanks for your answer.

    I've had similar thoughts but the idea of working with strings on the server instead of real WPF objects isn't really very attractive. A compromise would be to work with pure XML but for complicated graphics (mostly paths, lines, ellipses) a true object model would make it much more clean. Of course one could create custom classes, one for each graphic type but this seems like reinviting the wheel.

    As I see it the ideal solution would be to serialize a bunch of WPF objects into a XAML island on an ASP.NET page.

    Tim

    Thursday, January 25, 2007 8:13 PM
  • I also have idea with custom XAML template. But the mayor problem of custom template is the code behind. Example if we define a button on XAML file (for example the name is "button1") for all template. Then if we want to put code behind for that button (on the "window.xaml.cs"), how can we do that?

    Well for conventional way I usually put button on XAML, compile it, then at "window.xaml.cs" will automatically created variable "button1". Then at constructor we can put code like:
    this.button1.click = ...bla..bla...bla...
    But at dynamic template how can we do that? we only know the name? do with reflection we only allowed use type full name to create object (Assembly.CreateInstance(..type full name..))?

    Thanks for reply.
    Wednesday, March 14, 2007 2:47 PM