Développer en XAML
Merged Dictionary
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/Dictionaries/Primary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
MultiBinding
<code><!--FreeSpace-->
<TextBlock Name="txbSizeStats" Width="120" HorizontalAlignment="Center">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} Go / {1} Go">
<MultiBinding.Bindings>
<Binding Path="CurrentDriveItem.FreeSpace" />
<Binding Path="CurrentDriveItem.TotalSize" />
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</code>
Définir un style en code-behind
<code>// Création du nouveau bouton
HyperlinkButton newLink = new HyperlinkButton();
newLink.Content = item.Name;
newLink.Tag = item.HyperLink;
newLink.Style = (Style)this.Resources["NavHyperLinkStyle"];
</code>
Style Trigger
<code><!-- Style des list box pour alterner les couleurs -->
<Style x:Key="CustomListViewItemStyle" TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="Azure"/>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
</code>
Enumeration Converter
<code><Converters:BobBooleanConverter x:Key="BobBooleanConverter"/>
<ConvertersSuite:EnumerationConverter x:Key="EnumerationConverter"/>
<!--Fournisseur de données-->
<ObjectDataProvider x:Key="TypeCISValues" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
<ObjectDataProvider.MethodParameters>
<x:Type TypeName="Enums:TypeCIS"/>
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
</code>
Ressources
- [[http://msdn.microsoft.com/fr-fr/library/ms751709.aspx|Vue d'ensemble de l'alignement, des marges et du remplissage]]
- [[http://www.codeproject.com/articles/35346/Using-Resource-Dictionary-in-WPF.aspx|CodeProject: Using a Resource Dictionary in WPF. Free source code and programming help]]
Commentaires
Enregistrer un commentaire