Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a sub-class library of common controls?
Message
From
02/07/2008 13:43:15
 
 
To
All
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Title:
Creating a sub-class library of common controls?
Miscellaneous
Thread ID:
01328319
Message ID:
01328319
Views:
48
I want to subclass certain base controls before using them on my forms so I can have one central place to adjust the visual appreance of them.

I have this working in a file called MyControls.xaml, but I cannot figure out how to add a second class in this file.

Here it is with just one sub-classed control, a TextBlock:
<TextBlock x:Class="wpf2.FieldLabel"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    Foreground="Red">   
</TextBlock>  



But, when I add a second class into the file (for a TextBox), it gives me an error, saying 'There are multiple root elements. Line 9, position 6.' XML is not valid.
<TextBlock x:Class="wpf2.FieldLabel"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    Foreground="Red">   
</TextBlock>  
  
  
<TextBox x:Class="wpf2.FieldTextBox"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
   Foreground="Blue">   
</TextBox>  
So, how can I have multiple sub-classes in a file? Do I have to create one file for each sub-classed control?
Next
Reply
Map
View

Click here to load this message in the networking platform