Apply control template in XAML

It should be very simple. How to apply a ControlTemplate to Thumb in XAML?

<UserControl.Resources>
    <ControlTemplate x:Key="temp">
        <Ellipse Width="60" Height="30" Fill="Black"/>
    </ControlTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
    <TextBlock>Not Dragged</TextBlock>
    <Canvas x:Name="foo">
        <Thumb Width="150" Height="50" DragDelta="Thumb_DragDelta" x:Name="simpleDrag">

        </Thumb>
        <TextBlock>Dragged (hopefull)</TextBlock>
    </Canvas>
</Grid>

I can't figure out how to apply the temp template to Thumb. Thank!

+5
source share
1 answer

You used the property Template:

<Thumb Width="150" ... Template="{StaticResource temp}" />
+8
source

All Articles