How can I use multiple ControlTemplates in a XAML-file?

后端 未结 1 777
既然无缘
既然无缘 2021-01-23 05:57

I\'m having this annoying problem with WPF that I can\'t get my head around. What I\'m trying to create, is a very basic implementation of a drawing program (it\'s a school assi

相关标签:
1条回答
  • 2021-01-23 06:08

    ControlTemplate can only contain one child. Try and change it to a Canvas instead

            <Style x:Key="fillTool" TargetType="{x:Type Thumb}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Thumb}">
                            <Canvas>
                               <Ellipse HorizontalAlignment="Left" Height="19" Margin="310,330,0,0" VerticalAlignment="Top" Width="19" Fill="Blue"/>
                               <Ellipse HorizontalAlignment="Left" Height="12" Margin="317,316,0,0" VerticalAlignment="Top" Width="12" Fill="Blue"/>
                               <Ellipse HorizontalAlignment="Left" Height="8" Margin="307,320,0,0" VerticalAlignment="Top" Width="7" Fill="Blue"/>
                               <Ellipse HorizontalAlignment="Left" Height="3" Margin="317,302,0,0" VerticalAlignment="Top" Width="3" Fill="Blue"/>
                               <Ellipse HorizontalAlignment="Left" Height="5" Margin="311,310,0,0" VerticalAlignment="Top" Width="5" Fill="Blue"/>
                            </Canvas>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    
    0 讨论(0)
提交回复
热议问题