How do you completely remove the button border in wpf?

前端 未结 8 1305
花落未央
花落未央 2020-11-28 21:33

I\'m trying to create a button that has an image in it and no border - just like the Firefox toolbar buttons before you hover over them and see the full button.

I\'v

相关标签:
8条回答
  • 2020-11-28 21:59

    You may have to change the button template, this will give you a button with no frame what so ever, but also without any press or disabled effect:

        <Style x:Key="TransparentStyle" TargetType="{x:Type Button}">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border Background="Transparent">
                            <ContentPresenter/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    

    And the button:

    <Button Style="{StaticResource TransparentStyle}"/>
    
    0 讨论(0)
  • 2020-11-28 22:02

    Programmatically, you can do this:

    btn.BorderBrush = new SolidColorBrush(Colors.Transparent);
    
    0 讨论(0)
提交回复
热议问题