简体   繁体   中英

what is the best way to define label and TextBox

I can do it by define UserControl that will contain those 2 element. But is it possible to define it by define new style ?

I want to define something like on the bitmap attached. But i need to do it on a lot of places on my xaml.

在此处输入图片说明

by using a style for a HeaderedContentControl

    <HeaderedContentControl Header="Title" Content="what is the best way to define label and TextBox">
        <HeaderedContentControl.Template>
            <ControlTemplate TargetType="HeaderedContentControl">
                <StackPanel Orientation="Horizontal">
                    <Label Content="{TemplateBinding Header}"/>
                    <TextBox Text="{TemplateBinding Content}"/>
                </StackPanel>
            </ControlTemplate>
        </HeaderedContentControl.Template>
    </HeaderedContentControl>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM