提问者:小点点

自定义菜单不可点击


我正在尝试创建一个3水平点菜单。我下面的代码设置3个点很好,但是菜单不能被点击,并且没有显示标题为“删除项”的菜单项。

知道为什么吗?

<Window.Resources>
        <Style TargetType="{x:Type Menu}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Menu}">
                        <Canvas >
                            <Path Data="M12.5,6.5 C12.5,9.8137085 9.8137085,12.5 6.5,12.5 C3.1862915,12.5 0.5,9.8137085 0.5,6.5 C0.5,3.1862915 3.1862915,0.5 6.5,0.5 C9.8137085,0.5 12.5,3.1862915 12.5,6.5 z M30.5,6.5 C30.5,9.8137085 27.813708,12.5 24.5,12.5 C21.186292,12.5 18.5,9.8137085 18.5,6.5 C18.5,3.1862915 21.186292,0.5 24.5,0.5 C27.813708,0.5 30.5,3.1862915 30.5,6.5 z M48.5,6.5 C48.5,9.8137085 45.813708,12.5 42.5,12.5 C39.186292,12.5 36.5,9.8137085 36.5,6.5 C36.5,3.1862915 39.186292,0.5 42.5,0.5 C45.813708,0.5 48.5,3.1862915 48.5,6.5 z" 
                                    Fill="Black" 
                                    HorizontalAlignment="Left" 
                                    Stretch="Fill" 
                                    Stroke="Black"
                                    VerticalAlignment="Top" 
                                    Height="7" Width="23"/>
                        </Canvas>

                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
    </Window.Resources>
    <Grid>
        <Menu>
            <MenuItem Header="Remove item" FontSize="12" />
        </Menu>       
    </Grid> 

共1个答案

匿名用户

ControlTemplate应该包括要生成的子项的元素。