允许用户重新设置ControlTemplate的样式

时间:2018-11-20 19:09:25

标签: wpf wpf-controls

我正在尝试为ListBox创建一个自定义ControlTemplate,用户应该可以在其中修改某些零件的外观。可以说修改后的ControlTemplate如下所示:

<Setter Property="Template">
  <Setter.Value>
    <ControlTemplate>
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="Auto" />
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <RepeatButton ... />
        <ScrollViewer ... /> <!-- ScrollContentPresenter -->
        <RepeatButton ... />
      </Grid>
    </ControlTemplate>
  </Setter.Value>
</Setter>

如何允许这个CustomListBox控件的用户修改已添加的两个重复按钮的外观(内容)?我知道我需要在自定义控件中公开两个依赖项属性,但是如何将它们关联到上面的控件模板?

0 个答案:

没有答案