1. 程式人生 > >WPF 模板綁定父級控件內容

WPF 模板綁定父級控件內容

binding content 模板綁定 key per val setter class target

WPF 模板綁定父級控件內容

<Style TargetType="Button" x:Key="btn">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Label Content="{Binding Path=Content,RelativeSource={ RelativeSource Mode=TemplatedParent}}"></Label>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

WPF 模板綁定父級控件內容