wpf – 在XAML中应用控制模板

前端之家收集整理的这篇文章主要介绍了wpf – 在XAML中应用控制模板前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这应该很简单.如何在XAML中将ControlTemplate应用于Thumb?

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

我无法弄清楚如何将“临时”模板应用于Thumb.谢谢!

解决方法

您将使用 Template属性

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

猜你在找的Silverlight相关文章