View Full Version : 2 WPF Examples
03 March 2009, 11:18 AM
Hey guys, I've been digging WPF stuff and I came up with two simple examples...for me it's being fun to find out the new possibilities of this. Cheers.
dnButton.Content="WPF Button Test"
dnCanvas.SetTop dnButton 10
dnCanvas.SetLeft dnButton 10
XamlString="<Window \n xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"\n xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"\n Title=\"Window1\" Height=\"300\" Width=\"300\">\n <Grid>\n <Button Height=\"22\" HorizontalAlignment=\"Left\" Margin=\"12,12,0,0\" Name=\"Button1\" VerticalAlignment=\"Top\" Width=\"87\">Button</Button>\n <ComboBox Margin=\"0,12,12,0\" Name=\"ComboBox1\" Height=\"22\" VerticalAlignment=\"Top\" HorizontalAlignment=\"Right\" Width=\"122\" />\n <ListBox Margin=\"12,58,12,12\" Name=\"ListBox1\" />\n </Grid>\n</Window>"
I find the second example to have great habilities in terms of UI design for maxscripts :D
03 March 2009, 12:25 PM
cant get the 2nd example to work. I get this error:
-- Unknown property: "Parse" in dotNetClass:System.Windows.Markup.XamlReader
I can see the potential though. Dotnet windows / controls from xml!
03 March 2009, 12:39 PM
What Max version are you using? I'm using Max 2009 and they both work fine.
It's not quite XML, it's a little different, have a look here http://en.wikipedia.org/wiki/Windows_Presentation_Foundation and here http://en.wikipedia.org/wiki/Extensible_Application_Markup_Language
03 March 2009, 01:28 PM
i'm using 2009 as well. am i supposed to load a some dotnet assembly first?
03 March 2009, 01:37 PM
this error is much more fun ;)
-- Runtime error: dotNet runtime exception: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
( fresh max (2009x32) start )
03 March 2009, 02:46 PM
Sorry guys, my bad. You have to install .NET 3.5 SP1 :D I guess that's it.. and I'm using Max 2009 64 bit btw.
ZeBoxx2: you had that error in both examples?
Edit: About the Parse Method, this method is only available as .NET 3.5 SP1
03 March 2009, 02:59 PM
yep, both examples - quite possibly I don't have 3.5 (SP1 or otherwise) installed as of yet.. will try later.
Shouldn't we be building user interfaces in Adobe Flash, though? ;)
03 March 2009, 03:15 PM
Well, I ran into this because I was researching on how to create a windows form designer of my own but since I'm into it I guess I'll try to do it WPF compatible, since the XAML parsing into maxscript seems like a good idea and it resolves the problem of having to convert VB code or VC to maxscript to actually create the controls. This way, after parsing the XAML code it returns the main Window, from where we can access all controls.
03 March 2009, 05:11 AM
got the same errors as ZeBoxx2 with a fresh install of .NET 3.5 SP1 (2009x32 as well)
i'm guessing it's an issue w/ 32 bit instead of 64
03 March 2009, 10:29 AM
or maybe it's an XP vs Vista thing (apparently WPF is a separate download for XP SP2) - no idea :)
I did / do have .NET 3.5 (SP1) installed.. even tried re-installing, but the installer spends 5 minutes 'preparing', then pops up a dialog with a ton of knobs and buttons, then when going to install it just claims that Setup Failed :cool:
03 March 2009, 12:09 PM
This is weird... I have Windows XP SP2 64 bit... Haven't tried this on Vista. Well, it seems I have developed something that only I can run :D lol Any insight on why this is happening would be appreciated. Cheers guys.
03 March 2009, 04:51 PM
the only possibly relevant bit I can find is...
Window needs UnmanagedCode security permission to be instantiated. This has the following consequences:
ClickOnce-deployed standalone applications will request permission elevation when launched from either the Internet or Local Intranet zones.
XBAPs that request anything less than full permissions will not be able to instantiate windows or dialog boxes.
03 March 2009, 05:16 PM
Does 2009 officially support .net 3.5?
03 March 2009, 10:42 AM
Does 2009 officially support .net 3.5?
I have no ideia!
But have any of you guys tried this on 64 bit? I ran into this today: "running 32-bit code which tries to call 64-bit one and vice versa (this appears on 64bit machines, i.e. 64-bit CPU, Windows or .NET 2.0 version"
03 March 2009, 10:58 AM
no 64bit here, but the objects you're creating certainly aren't 64bit-only objects.. it's just a Window ;\
03 March 2009, 12:13 PM
Well, it seems I have developed something that only I can run :D
I know that feeling! you tend to forget things you install on the development computer until you deploy!
works fine for me, Artur on XP 64bit, but crashes Vista 32bit.
03 March 2009, 12:29 PM
forgot to say before i'm on XP 64bit. Also i checked my windows automatic update message today and .NET 3.5 service pack 1 was one of the updates so we'll see how i go once i get around to installing the update...
03 March 2009, 01:03 PM
Tha last thing I tried in this direction was hosting a wpf user control in a .net 2 window using elementHost. It worked outside 3ds, but not inside. Management not working, as far as I could see, access violations.
03 March 2009, 01:24 PM
Im seeing similar errors when i try to use lockbits from the bitmapdata class - it is using unmanaged resources to enhance speed but It gives me protected memory issues. Is WPF using unmanaged resources to do all the directx stuff?
03 March 2009, 04:12 PM
I just did a fresh install of Windows Vista Ultimate 64 SP1 and did all the updates via Windows Update (including the .Net 3.5 SP1), installed Max 2009 64 bit and executed both script examples with no problem :P (They look so pretty in Vista!)
I'm researching on the problem you guys are having but with no avail yet :\
03 March 2009, 05:43 PM
Everything seems to work perfectly here.
03 March 2009, 05:52 PM
seems to work fine here too, XP64 with .net3.5 (Thats a beastly install too.)
Looks interesting! how are you building your Xaml? i remember looking into that a long while back, but ended up not really needing it at the time.
03 March 2009, 05:59 PM
I'm using VS Express 2008 to create the UI, then I just copy/pasted the string to maxscript, I've already made some changes to load the .xaml file but I've been looking better at this and I'm not liking it :P I think I'll go back to my other approach which is developing a custom form designer that exports the form to maxscript :D hehe
03 March 2009, 05:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.