Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating a sub-class library of common controls?
Message
De
02/07/2008 13:43:15
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Titre:
Creating a sub-class library of common controls?
Divers
Thread ID:
01328319
Message ID:
01328319
Vues:
49
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?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform