0

次のコードがあります。

<Style x:Key="ComboBoxControlTemplate" TargetType="ComboBoxe">
    <Setter Property="FontSize" Value="25"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ComboBox}">
                <Grid>
                    <TextBox 
                        x:Name="PART_EditableTextBox" 
                        Template="{StaticResource TextBoxBaseControlTemplate}" 
                        FontSize="25" 
                        FontFamily="{StaticResource CommonFont}" 
                        FontWeight="Light"
                        TextChanged="EmployeeField_TextChanged"
                        GotFocus="EmployeeField_OnGotFocus"
                        LostFocus="EmployeeField_OnLostFocus"/>
                    <ContentPresenter Name="ContentSite" IsHitTestVisible="False"
                        Content="{TemplateBinding SelectionBoxItem}"
                        ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                        ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                        Margin="3,3,23,3"
                        VerticalAlignment="Center"
                        HorizontalAlignment="Left" />

                    <Popup 
                        Name="Popup"
                        Placement="Bottom"
                        IsOpen="{TemplateBinding IsDropDownOpen}"
                        AllowsTransparency="True" 
                        Focusable="False"
                        PopupAnimation="Slide">

                        <StackPanel Name="DropDown" SnapsToDevicePixels="True" IsItemsHost="True" Background="#FFEEEEEE" />
                    </Popup>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

ただし、少し問題があります。のStackPanel実際のアイテムを含む は、ComboBox各アイテムをパディングまたは周囲に何らかのマージンで表示します。各アイテムの下に境界線を含む、アイテムごとに別DataTemplateのものがあります。ComboBoxしかし、前述のパディングなどがあるため、境界線はPopup. 全体に広がる境界線が必要です。さらに、ユーザーが項目の上にマウスを置いたときに表示される色と境界線を指定できるようにする必要があります。

4

0 に答える 0