【问题标题】:Silverlight custom control's content in scrollviewer滚动查看器中的 Silverlight 自定义控件的内容
【发布时间】:2010-12-08 23:55:34
【问题描述】:

我有一个从 ContentControl 派生的 Silverlight 控件。 我按照以下方式使用它

<local:CustomControl>
 <local:AnotherControl>
</local:CustomControl>

我想在 ScrollViewer 中包含内容(即 AnotherControl)。 在不更改上述 XAML 用法的情况下,如何在滚动查看器中获取内容? CustomControl的模板需要做哪些修改?

谢谢

【问题讨论】:

    标签: silverlight custom-controls


    【解决方案1】:

    我找到了方法 我将控制模板定义如下

    <Style TargetType="local:MyCustomControl">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="local:MyCustomControl">
            <ScrollViewer>
              <Canvas>
               <ContentPresenter/>
              </Canvas>
            </ScrollViewer>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
    

    它对我有用。这是正确的方法吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-28
      • 2012-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-05
      • 1970-01-01
      相关资源
      最近更新 更多