WPF-样式组合框 [英] WPF - styling comboboxes

查看:62
本文介绍了WPF-样式组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在WPF中设置组合框的样式,使其为白色,并且具有与TextBoxes相同的边框。到目前为止,我有以下样式,但是不知道如何设置边框:

I'm trying to style Comboboxes in WPF so that they are white, and have the same border as TextBoxes. I have the following style so far, but don't know how to set the border:

<Style TargetType="ComboBox">
    <Setter Property="Margin" Value="0,2,0,2" />
    <Setter Property="VerticalAlignment" Value="Center" />
    <Setter Property="Background" Value="White" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type ComboBox}">
                 ???
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>


推荐答案

使用Expression Blend。如果要使 ComboBox 看起来与 TextBox 相似,请查看 TextBox 模板,方法是右键单击 TextBlock 并选择编辑模板>编辑副本,然后使用它来修改 ComboBox 模板!

Use Expression Blend. If you want ComboBox to look similar to TextBox, have a look at TextBox template by right clicking TextBlock and selecting Edit Template > Edit a Copy and use that to modify your ComboBox template!

这篇关于WPF-样式组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆