Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply Control Template in XAML

This should be really simple. How do I apply a ControlTemplate to a 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 the Thumb. Thanks!

like image 203
Adam Rackis Avatar asked Oct 19 '10 23:10

Adam Rackis


People also ask

What is a control template?

The ControlTemplate allows you to specify the visual structure of a control. The control author can define the default ControlTemplate and the application author can override the ControlTemplate to reconstruct the visual structure of the control.


1 Answers

You'd use the Template property:

<Thumb Width="150" ... Template="{StaticResource temp}" />
like image 91
Reed Copsey Avatar answered Nov 07 '22 07:11

Reed Copsey