xaml subclass???

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

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.
 
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! |
*******************************************
 
Gregory A. Beamer said:
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.
 
Gregory A. Beamer said:
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'.
 
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! |
*******************************************
 
Back
Top