Bonjour

voici un petit xaml pour vous mettre en bouche
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
 
<Window x:Class="SentinelSAS.Window2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:skins="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna"
    Title="Window2" Height="465" Width="300">
 
    <Window.Resources>
 
        <Style x:Key="MyComboBoxStyle" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource {x:Type ComboBox}}">
            <Style.Resources>
                <ResourceDictionary />
            </Style.Resources>
            <Setter Property="SnapsToDevicePixels" Value="true"/>
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
            <Setter Property="MinHeight" Value="20"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ComboBox">
                        <StackPanel Orientation="Horizontal">
                            <ToggleButton 
                                  Name="ToggleButton" 
                                  Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
                                  Background="{TemplateBinding Panel.Background}"
                                  Focusable="false"
                                  IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
                                  ClickMode="Press"
                            >
                            </ToggleButton>
                            <Popup 
                                  Name="Popup"
                                  Placement="Bottom"
                                  IsOpen="{TemplateBinding IsDropDownOpen}"
                                  Focusable="False"
                                  AllowsTransparency="True"
                                  PopupAnimation="Slide">
                                  <skins:SystemDropShadowChrome 
                                        Color="#00FFFFFF" 
                                        Name="Shdw" 
                                        MinWidth="{TemplateBinding FrameworkElement.ActualWidth}" 
                                        MaxHeight="{TemplateBinding ComboBox.MaxDropDownHeight}">
                                        <Border BorderThickness="1,1,1,1" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Name="DropDownBorder">
                                            <ScrollViewer>
                                                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" KeyboardNavigation.DirectionalNavigation="Contained" />
                                            </ScrollViewer>
                                        </Border>
                                    </skins:SystemDropShadowChrome>
                            </Popup>
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
 
 
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="74*" />
            <RowDefinition Height="58*" />
            <RowDefinition Height="18*" />
            <RowDefinition Height="30*" />
            <RowDefinition Height="82*" />
        </Grid.RowDefinitions>
 
        <DockPanel Grid.Row="1" x:Name="dockPanel1" >
 
            <ComboBox DockPanel.Dock="Right"   
                      Width="20"
                      Style="{StaticResource MyComboBoxStyle}"
                      x:Name="combox2" Grid.RowSpan="3">
                <ComboBoxItem>alpha sdsdfgdfgg</ComboBoxItem>
                <ComboBoxItem>alpha</ComboBoxItem>
                <ComboBoxItem>alphadfgdfgdfgdfdfdfdfgdfgdfgg</ComboBoxItem>
                <ComboBoxItem>alpha</ComboBoxItem>
                <ComboBoxItem>alpha</ComboBoxItem>
                <ComboBoxItem>alpha</ComboBoxItem>
            </ComboBox>
            <ToggleButton></ToggleButton>
            <Label Content="alpha" Background="Orange"></Label>
 
        </DockPanel>
        <ComboBox Grid.Row="3" Name="comboBox1" />
        <ListBox Grid.Row="4" Margin="8,13,0,21" 
                 ItemsSource="{Binding Path=Keys}"
                 x:Name="listBox1" HorizontalAlignment="Left" Width="120" />
        <Button Grid.Row="4" Height="36" HorizontalAlignment="Right" Margin="0,14,37,0" Name="button1" VerticalAlignment="Top" Width="100" Click="button1_Click">Button</Button>
        <Button Grid.Row="4" HorizontalAlignment="Right" Margin="0,59,31,32" Name="button2" Width="105">Button</Button>
    </Grid>
</Window>
voici donc mon probleme ....
vous avez note que je redefini la combobox en profitant pour supprimer quelques truc qui ne m'interesse plus du tout ...

par contre j'aimerais assez que mon bouton tooglebutton soit le meme
que celui de la combo box du theme standard

ainsi si je colle le code suivant
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
<ToggleButton 
                                  Name="ToggleButton" 
                                  Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
                                  Background="{TemplateBinding Panel.Background}"
                                  Focusable="false"
                                  IsChecked="{Binding Path=IsDropDownOpen,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}"
                                  ClickMode="Press"
                            >
                            </ToggleButton>
sur vista ca va a peut pres mais bon y manque la fleche vers le bas
sur xp c'est pas du tout top (!)
comment faut t'il faire pour binder le template (ou le style) de mon toggle button sur le template du combobox.togglebutton du theme en cours

j'ai un autre probleme un poil recurrant et semble t-il
c'est que j'ai le meme probleme avec le style ou le template du popup
(j'ai pas mis les triggers sur le hasdropshadow de celui ci mais promis je va le faire .... )

merci pour vos reponses