IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Presentation Foundation Discussion :

Petit probleme dans un menu WPF


Sujet :

Windows Presentation Foundation

  1. #1
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2009
    Messages
    91
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Maine et Loire (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2009
    Messages : 91
    Points : 65
    Points
    65
    Par défaut Petit probleme dans un menu WPF
    Bonjour, j'ai un petit souci lorsque je veux modifier la couleur d'un menu:

    Comme vous pouvez le voir, le menu est noir mais autour c'est blanc. Comment faire pour tout rendre noir sous expression blend (sans l'ecriture et le separateur).
    Merci d'avance.

  2. #2
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Points : 19 434
    Points
    19 434
    Par défaut
    Hum.. en modifiant le template ou en appliquant un style ?

  3. #3
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2009
    Messages
    91
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Maine et Loire (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2009
    Messages : 91
    Points : 65
    Points
    65
    Par défaut
    Je viens de trouver comment faire en manipulant un peu. Il fallait juste utilisé le pot de peinture blend. Merci quand meme ^^.

  4. #4
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2009
    Messages
    91
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Maine et Loire (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2009
    Messages : 91
    Points : 65
    Points
    65
    Par défaut
    Enfaite j'ai crié victoire trop vite. Dans expression blend sa s'affiche corectement mais quand je lance mon programme c'est pareil. Donc probleme non resolu. Pourrait tu m'expliquer comment changer de template ou de styles dans blend. Merci.

  5. #5
    Expert éminent sénior
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Février 2005
    Messages
    5 161
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2005
    Messages : 5 161
    Points : 12 276
    Points
    12 276
    Par défaut
    Connais-pas Blend mais il n'y a pas une propriété "Border" sur votre menu ?

  6. #6
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2009
    Messages
    91
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Maine et Loire (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2009
    Messages : 91
    Points : 65
    Points
    65
    Par défaut
    Il y'a l'option borderbrush mais pas border tout court. J'ai modifier cette propriété mais ca ne fait pas grand chose.

  7. #7
    Expert éminent sénior
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Février 2005
    Messages
    5 161
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2005
    Messages : 5 161
    Points : 12 276
    Points
    12 276
    Par défaut
    "BorderBrush", il suffit de lui associer une SolidBrush de la couleur voulue, non ?

  8. #8
    Membre expérimenté
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    1 562
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 562
    Points : 1 313
    Points
    1 313
    Par défaut
    ou alors tu le met a transparent #00xxxxxx
    ou la couleur transparente aussi
    sinon tu le met a {x:Null }

  9. #9
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2009
    Messages
    91
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Maine et Loire (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2009
    Messages : 91
    Points : 65
    Points
    65
    Par défaut
    J'ai essayer mais c'est pas sa non plus. Mes je pense enfaite qu'il faudrai mettre en noir la partie blanche et non pas la mettre transparente. Par contre sa je n'ai pas trouvé comment faire. Si vous pouvez m'aider, merci.

  10. #10
    Membre expérimenté
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    1 562
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 562
    Points : 1 313
    Points
    1 313
    Par défaut
    tu as essayé d'introspecter avec blend les style et les templates ?

  11. #11
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2009
    Messages
    91
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Maine et Loire (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2009
    Messages : 91
    Points : 65
    Points
    65
    Par défaut
    Ben je crois pas. Je debute avec blend en plus. Mais je ne sais pas trop ou aller.

  12. #12
    Membre expérimenté
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    1 562
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 562
    Points : 1 313
    Points
    1 313
    Par défaut
    tu as quelle blend ?

  13. #13
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2009
    Messages
    91
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Maine et Loire (Pays de la Loire)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2009
    Messages : 91
    Points : 65
    Points
    65
    Par défaut
    Expression blend 3.

  14. #14
    Membre expérimenté
    Profil pro
    Inscrit en
    Juillet 2008
    Messages
    1 562
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 562
    Points : 1 313
    Points
    1 313
    Par défaut
    bon
    tu selection l'objet dans object and timeline
    puis tu vas dans le menu
    object > edit Style > edit a copy
    puis tu verra en haut dessous l'onglet de ta fenetre tu as une indication avec une petite palette tu vas sur editer le template
    ca rajoute le code dans le xaml que tu as choisi quand tu as fait edit style (pour le moment choisi la fenetre)
    apres avec le clique droit sur chaque element tu peux a nouveau introspecter et changer les templates

    voici que que j'ai obtenu en le faisant

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
     
    <Window
    	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    	xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna"
    	x:Class="Design_menu.MainWindow"
    	x:Name="Window"
    	Title="MainWindow"
    	Width="640" Height="480">
     
    	<Window.Resources>
    		<PathGeometry x:Key="Checkmark" Figures="M0,2 L0,4.8 L2.5,7.4 L7.1,2.8 L7.1,0 L2.5,4.6 z"/>
     
    		<ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
    			<Border x:Name="Bd" SnapsToDevicePixels="true" Background="Aqua" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
    				<Grid>
    					<Grid.ColumnDefinitions>
    						<ColumnDefinition SharedSizeGroup="MenuItemIconColumnGroup" MinWidth="17" Width="Auto"/>
    						<ColumnDefinition Width="*"/>
    						<ColumnDefinition SharedSizeGroup="MenuItemIGTColumnGroup" Width="Auto"/>
    						<ColumnDefinition Width="14"/>
    					</Grid.ColumnDefinitions>
    					<ContentPresenter x:Name="Icon" Margin="4,0,6,0" VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Icon"/>
    					<Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Margin="4,0,6,0" VerticalAlignment="Center" Visibility="Hidden" Data="{StaticResource Checkmark}"/>
    					<ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True"/>
    					<TextBlock x:Name="InputGestureText" Margin="5,2,0,2" Grid.Column="2" Text="{TemplateBinding InputGestureText}" DockPanel.Dock="Right"/>
    				</Grid>
    			</Border>
    			<ControlTemplate.Triggers>
    				<Trigger Property="Icon" Value="{x:Null}">
    					<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
    				</Trigger>
    				<Trigger Property="IsChecked" Value="true">
    					<Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
    					<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
    				</Trigger>
    				<Trigger Property="IsHighlighted" Value="true">
    					<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
    					<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
    				</Trigger>
    				<Trigger Property="IsEnabled" Value="false">
    					<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
    				</Trigger>
    			</ControlTemplate.Triggers>
    		</ControlTemplate>
    		<Style x:Key="MenuScrollButton" BasedOn="{x:Null}" TargetType="{x:Type RepeatButton}">
    			<Setter Property="ClickMode" Value="Hover"/>
    			<Setter Property="MinWidth" Value="0"/>
    			<Setter Property="MinHeight" Value="0"/>
    			<Setter Property="Template">
    				<Setter.Value>
    					<ControlTemplate TargetType="{x:Type RepeatButton}">
    						<DockPanel SnapsToDevicePixels="true" Background="Transparent">
    							<Rectangle x:Name="R1" Fill="Transparent" Width="1" DockPanel.Dock="Right"/>
    							<Rectangle x:Name="B1" Fill="Transparent" Height="1" DockPanel.Dock="Bottom"/>
    							<Rectangle x:Name="L1" Fill="Transparent" Width="1" DockPanel.Dock="Left"/>
    							<Rectangle x:Name="T1" Fill="Transparent" Height="1" DockPanel.Dock="Top"/>
    							<ContentPresenter x:Name="ContentContainer" HorizontalAlignment="Center" Margin="2,2,2,2" VerticalAlignment="Center"/>
    						</DockPanel>
    						<ControlTemplate.Triggers>
    							<Trigger Property="IsPressed" Value="true">
    								<Setter Property="Fill" TargetName="R1" Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"/>
    								<Setter Property="Fill" TargetName="B1" Value="{DynamicResource {x:Static SystemColors.ControlLightLightBrushKey}}"/>
    								<Setter Property="Fill" TargetName="L1" Value="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"/>
    								<Setter Property="Fill" TargetName="T1" Value="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"/>
    								<Setter Property="Margin" TargetName="ContentContainer" Value="3,3,1,1"/>
    							</Trigger>
    						</ControlTemplate.Triggers>
    					</ControlTemplate>
    				</Setter.Value>
    			</Setter>
    		</Style>
    		<Geometry x:Key="UpArrow">M 0,4 L 3.5,0 L 7,4 Z</Geometry>
    		<MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter"/>
    		<Geometry x:Key="DownArrow">M 0,0 L 3.5,4 L 7,0 Z</Geometry>
    		<Style x:Key="{ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}" BasedOn="{x:Null}" TargetType="{x:Type ScrollViewer}">
    			<Setter Property="HorizontalScrollBarVisibility" Value="Hidden"/>
    			<Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
    			<Setter Property="Template">
    				<Setter.Value>
    					<ControlTemplate TargetType="{x:Type ScrollViewer}">
    						<Grid SnapsToDevicePixels="true">
    							<Grid.ColumnDefinitions>
    								<ColumnDefinition Width="*"/>
    							</Grid.ColumnDefinitions>
    							<Grid.RowDefinitions>
    								<RowDefinition Height="Auto"/>
    								<RowDefinition Height="*"/>
    								<RowDefinition Height="Auto"/>
    							</Grid.RowDefinitions>
    							<Border Grid.Column="0" Grid.Row="1">
    								<ScrollContentPresenter Margin="{TemplateBinding Padding}"/>
    							</Border>
    							<RepeatButton Style="{StaticResource MenuScrollButton}" Focusable="false" Grid.Column="0" Grid.Row="0" Command="{x:Static ScrollBar.LineUpCommand}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">
    								<RepeatButton.Visibility>
    									<MultiBinding FallbackValue="Visibility.Collapsed" Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="0">
    										<Binding Path="ComputedVerticalScrollBarVisibility" RelativeSource="{RelativeSource TemplatedParent}"/>
    										<Binding Path="VerticalOffset" RelativeSource="{RelativeSource TemplatedParent}"/>
    										<Binding Path="ExtentHeight" RelativeSource="{RelativeSource TemplatedParent}"/>
    										<Binding Path="ViewportHeight" RelativeSource="{RelativeSource TemplatedParent}"/>
    									</MultiBinding>
    								</RepeatButton.Visibility>
    								<Path Fill="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}" Data="{StaticResource UpArrow}"/>
    							</RepeatButton>
    							<RepeatButton Style="{StaticResource MenuScrollButton}" Focusable="false" Grid.Column="0" Grid.Row="2" Command="{x:Static ScrollBar.LineDownCommand}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}">
    								<RepeatButton.Visibility>
    									<MultiBinding FallbackValue="Visibility.Collapsed" Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="100">
    										<Binding Path="ComputedVerticalScrollBarVisibility" RelativeSource="{RelativeSource TemplatedParent}"/>
    										<Binding Path="VerticalOffset" RelativeSource="{RelativeSource TemplatedParent}"/>
    										<Binding Path="ExtentHeight" RelativeSource="{RelativeSource TemplatedParent}"/>
    										<Binding Path="ViewportHeight" RelativeSource="{RelativeSource TemplatedParent}"/>
    									</MultiBinding>
    								</RepeatButton.Visibility>
    								<Path Fill="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}" Data="{StaticResource DownArrow}"/>
    							</RepeatButton>
    						</Grid>
    					</ControlTemplate>
    				</Setter.Value>
    			</Setter>
    		</Style>
    		<ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
    			<Border x:Name="Bd" SnapsToDevicePixels="true" Background="Blue" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
    				<DockPanel>
    					<ContentPresenter x:Name="Icon" Margin="4,0,6,0" VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Icon"/>
    					<Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Margin="4,0,6,0" VerticalAlignment="Center" Visibility="Collapsed" Data="{StaticResource Checkmark}"/>
    					<ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header" RecognizesAccessKey="True"/>
    					<Popup x:Name="PART_Popup" AllowsTransparency="true" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" Focusable="false">
    						<Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">
    							<Border x:Name="SubMenuBorder" Background="{DynamicResource {x:Static SystemColors.MenuBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" BorderThickness="1">
    								<ScrollViewer Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}" CanContentScroll="true">
    									<ItemsPresenter Margin="2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.IsSharedSizeScope="true" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle"/>
    								</ScrollViewer>
    							</Border>
    						</Microsoft_Windows_Themes:SystemDropShadowChrome>
    					</Popup>
    				</DockPanel>
    			</Border>
    			<ControlTemplate.Triggers>
    				<Trigger Property="IsSuspendingPopupAnimation" Value="true">
    					<Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None"/>
    				</Trigger>
    				<Trigger Property="Icon" Value="{x:Null}">
    					<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
    				</Trigger>
    				<Trigger Property="IsChecked" Value="true">
    					<Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
    					<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
    				</Trigger>
    				<Trigger Property="IsHighlighted" Value="true">
    					<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
    					<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
    				</Trigger>
    				<Trigger Property="IsEnabled" Value="false">
    					<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
    				</Trigger>
    				<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
    					<Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
    					<Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
    				</Trigger>
    			</ControlTemplate.Triggers>
    		</ControlTemplate>
    		<ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
    			<Border x:Name="Bd" SnapsToDevicePixels="true" Background="Green" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
    				<DockPanel>
    					<ContentPresenter x:Name="Icon" Margin="4,0,6,0" VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Icon"/>
    					<Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Margin="4,0,6,0" VerticalAlignment="Center" Visibility="Collapsed" Data="{StaticResource Checkmark}"/>
    					<ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header" RecognizesAccessKey="True"/>
    				</DockPanel>
    			</Border>
    			<ControlTemplate.Triggers>
    				<Trigger Property="Icon" Value="{x:Null}">
    					<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
    				</Trigger>
    				<Trigger Property="IsChecked" Value="true">
    					<Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
    					<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
    				</Trigger>
    				<Trigger Property="IsHighlighted" Value="true">
    					<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
    					<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
    				</Trigger>
    				<Trigger Property="IsEnabled" Value="false">
    					<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
    				</Trigger>
    			</ControlTemplate.Triggers>
    		</ControlTemplate>
    		<Geometry x:Key="RightArrow">M 0,0 L 4,3.5 L 0,7 Z</Geometry>
    		<ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
    			<Border x:Name="Bd" SnapsToDevicePixels="true" Background="Blue" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
    				<Grid>
    					<Grid.ColumnDefinitions>
    						<ColumnDefinition SharedSizeGroup="MenuItemIconColumnGroup" MinWidth="17" Width="Auto"/>
    						<ColumnDefinition Width="*"/>
    						<ColumnDefinition SharedSizeGroup="MenuItemIGTColumnGroup" Width="Auto"/>
    						<ColumnDefinition Width="14"/>
    					</Grid.ColumnDefinitions>
    					<ContentPresenter x:Name="Icon" Margin="4,0,6,0" VerticalAlignment="Center" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Icon"/>
    					<Path x:Name="GlyphPanel" Fill="{TemplateBinding Foreground}" FlowDirection="LeftToRight" Margin="4,0,6,0" VerticalAlignment="Center" Visibility="Hidden" Data="{StaticResource Checkmark}"/>
    					<ContentPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True"/>
    					<Path Fill="{TemplateBinding Foreground}" Margin="4,0,6,0" VerticalAlignment="Center" Grid.Column="3" DockPanel.Dock="Right" Data="{StaticResource RightArrow}"/>
    					<Popup x:Name="PART_Popup" AllowsTransparency="true" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Right" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" VerticalOffset="-3" Focusable="false">
    						<Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">
    							<Border x:Name="SubMenuBorder" Background="{DynamicResource {x:Static SystemColors.MenuBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" BorderThickness="1">
    								<ScrollViewer Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}" CanContentScroll="true">
    									<ItemsPresenter Margin="2" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Grid.IsSharedSizeScope="true" KeyboardNavigation.DirectionalNavigation="Cycle" KeyboardNavigation.TabNavigation="Cycle"/>
    								</ScrollViewer>
    							</Border>
    						</Microsoft_Windows_Themes:SystemDropShadowChrome>
    					</Popup>
    				</Grid>
    			</Border>
    			<ControlTemplate.Triggers>
    				<Trigger Property="IsSuspendingPopupAnimation" Value="true">
    					<Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None"/>
    				</Trigger>
    				<Trigger Property="Icon" Value="{x:Null}">
    					<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
    				</Trigger>
    				<Trigger Property="IsChecked" Value="true">
    					<Setter Property="Visibility" TargetName="GlyphPanel" Value="Visible"/>
    					<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
    				</Trigger>
    				<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
    					<Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
    					<Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
    				</Trigger>
    				<Trigger Property="IsHighlighted" Value="true">
    					<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
    					<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
    				</Trigger>
    				<Trigger Property="IsEnabled" Value="false">
    					<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
    				</Trigger>
    			</ControlTemplate.Triggers>
    		</ControlTemplate>
     
    		<Style x:Key="MenuItemStyle1" TargetType="{x:Type MenuItem}">
    			<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
    			<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
    			<Setter Property="Background" Value="Red"/>
    			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/>
    			<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
    			<Style.Triggers>
    				<Trigger Property="Role" Value="TopLevelHeader">
    					<Setter Property="Margin" Value="0,1,0,1"/>
    					<Setter Property="Padding" Value="6,3,6,3"/>
    					<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
    				</Trigger>
    				<Trigger Property="Role" Value="TopLevelItem">
    					<Setter Property="Margin" Value="0,1,0,1"/>
    					<Setter Property="Padding" Value="6,3,6,3"/>
    					<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=TopLevelItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
    				</Trigger>
    				<Trigger Property="Role" Value="SubmenuHeader">
    					<Setter Property="DockPanel.Dock" Value="Top"/>
    					<Setter Property="Padding" Value="0,2,0,2"/>
    					<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
    				</Trigger>
    				<Trigger Property="Role" Value="SubmenuItem">
    					<Setter Property="DockPanel.Dock" Value="Top"/>
    					<Setter Property="Padding" Value="0,2,0,2"/>
    				</Trigger>
    			</Style.Triggers>
    		</Style>
    		<Style x:Key="MenuStyle1" TargetType="{x:Type Menu}">
    			<Setter Property="FontFamily" Value="{DynamicResource {x:Static SystemFonts.MenuFontFamilyKey}}"/>
    			<Setter Property="FontSize" Value="{DynamicResource {x:Static SystemFonts.MenuFontSizeKey}}"/>
    			<Setter Property="FontStyle" Value="{DynamicResource {x:Static SystemFonts.MenuFontStyleKey}}"/>
    			<Setter Property="FontWeight" Value="{DynamicResource {x:Static SystemFonts.MenuFontWeightKey}}"/>
    			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.MenuTextBrushKey}}"/>
    			<Setter Property="VerticalContentAlignment" Value="Center"/>
    			<Setter Property="Template">
    				<Setter.Value>
    					<ControlTemplate TargetType="{x:Type Menu}">
    						<Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
    							<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
    						</Border>
    					</ControlTemplate>
    				</Setter.Value>
    			</Setter>
    			<Setter Property="Background">
    				<Setter.Value>
    					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    						<GradientStop Color="#FFD4D4D4" Offset="0.938"/>
    						<GradientStop Color="Black" Offset="1"/>
    					</LinearGradientBrush>
    				</Setter.Value>
    			</Setter>
    		</Style>
    	</Window.Resources>
     
    	<Grid x:Name="LayoutRoot">
    		<Menu Margin="1,-1,0,0" VerticalAlignment="Top" Height="22" Style="{DynamicResource MenuStyle1}">
    			<MenuItem Margin="0" Style="{DynamicResource MenuItemStyle1}" Header="MenuItem" Background="#00FF0000">
    				<MenuItem Header="MenuItem"/>
    				<MenuItem Header="MenuItem"/>
    				<MenuItem Header="MenuItem"/>
    			</MenuItem>
    			<MenuItem Margin="0" Header="MenuItem"/>
    		</Menu>
    	</Grid>
    </Window>
    a mon avis le cadre c'est le premier controltemplate soit SubmenuItemTemplateKey

Discussions similaires

  1. petit probleme dans amarok
    Par PhiberOptik dans le forum KDE
    Réponses: 1
    Dernier message: 19/07/2007, 21h22
  2. un petit probleme dans mon code
    Par hanene_z dans le forum C
    Réponses: 9
    Dernier message: 22/12/2006, 17h06
  3. Réponses: 6
    Dernier message: 02/08/2006, 17h24
  4. petit probleme dans un code : theoreme de pythagore
    Par ETI-trian dans le forum C++
    Réponses: 3
    Dernier message: 15/10/2005, 13h13
  5. petit probleme dans une requte POSTGRE SQL
    Par ghis le fou dans le forum Requêtes
    Réponses: 5
    Dernier message: 08/09/2003, 13h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo