相关疑难解决方法(0)

如何在XAML中实现圆形按钮

如何在XAML中实现如下所示的圆形按钮,无需外部图像.不需要中间的黑线.

在此输入图像描述

.net wpf xaml

25
推荐指数
2
解决办法
5万
查看次数

WPF中的圆角平面按钮

我正在设计一个带有圆形平面按钮的WPF UI.我为这种按钮编写了以下代码:

<Border BorderThickness="1"
        BorderBrush="Transparent"
        Background="DarkCyan"
        CornerRadius="4"
        Height="35"
        Width="75">
            <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                    Content="Enter"
                    VerticalAlignment="Stretch"
                    HorizontalAlignment="Stretch"
                    Background="DarkCyan"
                    Foreground="White"/>
</Border>
Run Code Online (Sandbox Code Playgroud)

这个按钮的风格正是我所需要的.但是在运行时,当鼠标移动到按钮时,它不再被舍入.它是一个大小相同的矩形.实际上,按钮会溢出边框.所以我padding像这样添加到边框:

<Border BorderThickness="1"
        BorderBrush="Transparent"
        Background="DarkCyan"
        CornerRadius="4"
        Height="35"
        Width="75"
        Padding="2">
            <Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"
                    Content="Enter"
                    VerticalAlignment="Stretch"
                    HorizontalAlignment="Stretch"
                    Background="DarkCyan"
                    Foreground="White"/>
</Border>
Run Code Online (Sandbox Code Playgroud)

在这种情况下,按钮hoover mode不再溢出边框,但它仍然是矩形,因此按钮的颜色(In hoover mode)在此矩形和边框的其他空格中不同.所以不幸的是它还没用.

现在我的问题是:有没有办法建立一个角落圆形的平面按钮(就像我提到的那个),标记空间移动到按钮上将是角落圆形空间?

wpf

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

wpf ×2

.net ×1

xaml ×1