Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista Tutorial - xaml subclass???

Reply
 
Old 06-29-2009   #1 (permalink)
dave
Guest


 
 

xaml subclass???

I am not even sure that is the right term for this. I am not sure where to
really start looking for this capability.

I created a form using wpf. it is mostly a big TreeView with a couple
different TreeViewItems, each of which is a Grid of other controls. I
decided I wanted to be able to reuse some of the TreeViewItems in other
forms. Doing what made sense I created a new class library project, copied
the big form, broke out the pieces i wanted into their own classes, each
derived from TreeViewItem. The first problem is that in the class library
the designer reports that the root element (a TreeViewItem) is not supported.
Ignoring that I went back to the main project and ripped out the
TreeViewItems and replaced them with the classes from the class library
project. The compiler is happy, but the designer doesn't show the items, and
neither do they show in the app when running.

Obviously I am missing something here, but I'm not sure what to even start
searching on.

My System SpecsSystem Spec
Old 06-29-2009   #2 (permalink)
Gregory A. Beamer
Guest


 
 

Re: xaml subclass???

=?Utf-8?B?ZGF2ZQ==?= <epridave@xxxxxx> wrote in
news:3CD34E7D-106D-4035-8756-46659608E6F8@xxxxxx:

Quote:

> Obviously I am missing something here, but I'm not sure what to even
> start searching on.
>
I am not sure about the runtime issue, but XAML does not currently support
"visual inheritance", so I am not sure you can solve the design time
problem easily.

As far as runtime goes, you need to look at the final XAML and you will
likely be able to get a clue what is going wrong. Not sure how to do in
WPF; it is a bit easier in XBAP and Silverlight.


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
My System SpecsSystem Spec
Old 06-30-2009   #3 (permalink)
dave
Guest


 
 

Re: xaml subclass???



"Gregory A. Beamer" wrote:
Quote:

> =?Utf-8?B?ZGF2ZQ==?= <epridave@xxxxxx> wrote in
> news:3CD34E7D-106D-4035-8756-46659608E6F8@xxxxxx:
>
>
Quote:

> > Obviously I am missing something here, but I'm not sure what to even
> > start searching on.
> >
>
> I am not sure about the runtime issue, but XAML does not currently support
> "visual inheritance", so I am not sure you can solve the design time
> problem easily.
>
> As far as runtime goes, you need to look at the final XAML and you will
> likely be able to get a clue what is going wrong. Not sure how to do in
> WPF; it is a bit easier in XBAP and Silverlight.
>
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> Twitter: @gbworld
> Blog: http://gregorybeamer.spaces.live.com
>
> *******************************************
> | Think outside the box! |
> *******************************************
>
i definately do my best thinking outside the box... unless you consider the
shower a box.


well, it looks like i was on the right track with my first guess. I was
missing a call to InitializeComponent() in each of the sub classes though
which let them build but they wouldn't do anything when it ran. I also had
to take it one step further and create my own common base class for the sub
classes which made the namespaces for the xaml a bit uglier, but it works now
anyway.
My System SpecsSystem Spec
Old 06-30-2009   #4 (permalink)
dave
Guest


 
 

Re: xaml subclass???



"Gregory A. Beamer" wrote:
Quote:

> =?Utf-8?B?ZGF2ZQ==?= <epridave@xxxxxx> wrote in
> news:3CD34E7D-106D-4035-8756-46659608E6F8@xxxxxx:
>
>
Quote:

> > Obviously I am missing something here, but I'm not sure what to even
> > start searching on.
> >
>
> I am not sure about the runtime issue, but XAML does not currently support
> "visual inheritance", so I am not sure you can solve the design time
> problem easily.
>
> As far as runtime goes, you need to look at the final XAML and you will
> likely be able to get a clue what is going wrong. Not sure how to do in
> WPF; it is a bit easier in XBAP and Silverlight.
>
>
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> Twitter: @gbworld
> Blog: http://gregorybeamer.spaces.live.com
>
> *******************************************
> | Think outside the box! |
> *******************************************
>
p.s. it is interesting that now the main app designer window shows the
contents of the subclassed TreeViewItems, but the designers for the
individual subclasses still show the message 'the document root element is
not supported by the visual designer'.
My System SpecsSystem Spec
Old 07-07-2009   #5 (permalink)
Gregory A. Beamer
Guest


 
 

Re: xaml subclass???

=?Utf-8?B?ZGF2ZQ==?= <epridave@xxxxxx> wrote in
news:1FE08864-C65D-4BB9-B963-2BC52BBAFD65@xxxxxx:

Quote:

>
> p.s. it is interesting that now the main app designer window shows the
> contents of the subclassed TreeViewItems, but the designers for the
> individual subclasses still show the message 'the document root
> element is not supported by the visual designer'.

I have grown to expect bizarre behavior as the different bits are developed
in isolation. The closer you are to the bleeding edge, the worse it is.


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Base class defined and initialized variables loose initialization in subclass. .NET General
Is it possible to include XAML files into another XAML file? .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46