开发者

Silverlight custom control's content in scrollviewer

I have a Silverlight control derived from ContentControl. I use it in following way

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

I want to have the content (i.e. AnotherControl开发者_JAVA百科) in a ScrollViewer. Without changing the above XAML usage, how can I have the content in scrollviewer? What modification do I need to make in CustomControl's template?

Thanks


I found the way to do this I defined control template as following

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

Its working for me. Is it the proper way?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜