views:

271

answers:

1

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) 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

A: 

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?

NKC1