custom combobox-Komponente in wpf-Anwendung

Im neuen WPF-Anwendung. Muss ich passen meine combobox wie dieses Bild.custom combobox-Komponente in wpf-Anwendung

Ich habe dieses Beispiel ausprobiert
http://www.eidias.com/Blog/2012/2/20/customizing-wpf-combo-box-style

    <Window x:Class="win.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1"  Height="300" Width="300" Background="Red">
    <Window.Resources>
        <ControlTemplate x:Key="CustomToggleButton" TargetType="ToggleButton">
            <Grid>
                <Border Name="Border" />
                <Border Name="SmallBorder" />
                <Path Name="Arrow" />
            </Grid>
        </ControlTemplate>
        <Style TargetType="{x:Type ComboBoxItem}">
            <Setter Property="FrameworkElement.OverridesDefaultStyle" Value="True" />
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ComboBoxItem}">
                        <Border>
                            <ContentPresenter />
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style TargetType="{x:Type ComboBox}">
            <Setter Property="FrameworkElement.OverridesDefaultStyle" Value="True" />
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ComboBox">
                        <Grid>
                            <ToggleButton Template="{StaticResource CustomToggleButton}" />
                            <ContentPresenter />
                            <TextBox />
                            <Popup>
                                <Grid>
                                    <Border>
                                        <ScrollViewer>
                                            <ItemsPresenter />
                                        </ScrollViewer>
                                    </Border>
                                </Grid>
                            </Popup>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <ComboBox Grid.Column="1" Height="40" Width="200" >
            <ComboBoxItem Name="item1">item1</ComboBoxItem>
            <ComboBoxItem Name="item2">item2</ComboBoxItem>
            <ComboBoxItem Name="item3">item3</ComboBoxItem>
        </ComboBox>
    </Grid>
</Window>

Dieser Ausgabe funktioniert wie textbox.Bitte helfen Sie mir, Jungs!

InformationsquelleAutor ganesh | 2013-05-06
Schreibe einen Kommentar