Les Snippets

Connexion

Afficher toutes les couleurs disponible avec WPF

Niveau requis pour utiliser/comprendre cette source : 1 ( Débutant )
Créé le 10/04/2008 19:44:35 et initié par Bidou [Liste]
Date de mise à jour : 10/04/2008 21:04:09
Vue : 3181
Catégorie(s) : Trucs & Astuces, Graphique, Control
Langages dispo pour ce code :
- C# 3.x



Langage : C# 3.x
Date ajout : 10/04/2008
Posté par Bidou [Liste]
DateMAJ : 10/04/2008
Code

namespace WpfApplication 
{
   public class Tools
   {
      public PropertyInfo[] GetColors(Type type)
      {
         return type.GetProperties();
      }
   }
}

XAML

<Window x:Class="WpfApplication1.Window1" 
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns:local="clr-namespace:WpfApplication"
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
Title="Window1" Height="200" Width="300">
   <Window.Resources>
      <ObjectDataProvider x:Key="colors" MethodName="GetColors" ObjectType="{x:Type local:Tools}">
         <ObjectDataProvider.MethodParameters>
            <x:Type TypeName="Colors"/>
         </ObjectDataProvider.MethodParameters>
      </ObjectDataProvider>
      <DataTemplate x:Key="dTemplate">
         <StackPanel Orientation="Horizontal">
            <Rectangle Width="16" Height="12" Fill="{Binding Name}" Stroke="#FF000000"/>
            <TextBlock Margin="1" Text ="{Binding Name}" Foreground="{Binding Name}" />
         </StackPanel>
      </DataTemplate>
   </Window.Resources>
   <Grid>
      <ComboBox ItemsSource="{Binding Mode=OneWay, Source={StaticResource colors}}" ItemTemplate="{DynamicResource dTemplate}" Margin="50,50,50,0" VerticalAlignment="Top" />
   </Grid>
</Window>



Remarque :
N'oubliez pas de mettre le bon namespace...

Snippets en rapport avec : Combobox, Colors, Color, Binding, Wpf



Codes sources en rapport avec : Combobox, Colors, Color, Binding, Wpf

{Javascript / DHTML} PLAY COLORS V2.0
A little source when you click on the color of the left table it change in the right and if you clic...

{C# / C#.NET} [WPF]LINQUERY - INTERFACE DE GESTION DE DATABASE
LinQuery est une interface de gestion de base de donnée Access et SQL Server, écrit en C# via WPF. ...

{C# / C#.NET} CRÉATION ET ENVOI DE FICHIERS ZIPPÉS
Ce petit prog fait en wpf permet de zipper le contenu d'un dossier en excluant les fichiers binaires...

{C# / C#.NET} DESIGNER DE WORKFLOW WF4 WPF AVEC RIBBON OFFICE
Ce code est destiner à démontrer les possibilités de rehosting du designer de WF4. La solution cont...

{Visual Basic, VB6, VB.NET, VB 2005} VBA EXCEL AFFICHER UN NUANCIER DES COULEURS AFIN DE CHOISIR UN CODE COLORINDEX A METTRE DANS LE VBA
Cette routine génère dans la feuille active un nuancier des codes couleurs d'Excel (attention de ...

{C# / C#.NET} TOOLTIP TEXT POUR LA LISTE DÉROULANTE D'UN COMBOBOX
Ce code permet d'afficher un ToolTip lors du survol de la dropdwonlist d'un combobox. Cette fonctio...

{C# / C#.NET} SODOKU MUSING (PERMUTATION & SODOKU)
Une application WPF représentant un Sodoku. Elle permet de manipuler un Sodoku en permutant ses lig...

{C# / C#.NET} ROBOT À DESSINER
Quand j'étais petit, sur les MO5 de mon école, nous avions le droit à un langage de programmation qu...

{C# / C#.NET} [WPF .NET 3.5] USER CONTROL INFO BOX
Bonjour. Ce petit control se veut reprendre le principe de l'info bulle standard. Il peut affi...

{C# / C#.NET} CAROUSEL EN WPF (USERCONTROL)
Cette source contient un UserControl qui permet d'insérer assez aisément un "Carousel" dans son appl...