You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何隐藏MaterialDesign WPF中PopupBox的白色边框

解决MaterialDesign PopupBox弹窗出现白色边框的问题

针对你遇到的PopupBox弹窗出现两条白色边框的问题,给你几个可行的解决办法:

方法一:直接覆盖PopupBox的弹出边框属性

MaterialDesign的PopupBox默认会给弹出容器添加边框,你可以直接在控件上设置相关属性来去掉:

<materialDesign:PopupBox StaysOpen="False" PlacementMode="BottomAndAlignCentres"
                         PopupBorderBrush="Transparent"
                         PopupBorderThickness="0">
    <!-- 你的原有内容 -->
</materialDesign:PopupBox>

方法二:修改PopupBox内部边框样式

如果方法一没生效,可能是默认样式优先级更高,你可以在PopupBox的资源里重写弹出边框的样式:

<materialDesign:PopupBox StaysOpen="False" PlacementMode="BottomAndAlignCentres">
    <materialDesign:PopupBox.Resources>
        <Style TargetType="Border" x:Key="MaterialDesign.PopupBox.PopupBorder">
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="0"/>
            <!-- 若想同时去掉阴影,可添加此行 -->
            <Setter Property="Effect" Value="{x:Null}"/>
        </Style>
    </materialDesign:PopupBox.Resources>
    
    <!-- 你的原有ToggleContent和弹出内容 -->
</materialDesign:PopupBox>

方法三:确保Popup透明设置正确

虽然你说设置过AllowsTransparency没生效,但要确认是给PopupBox本身设置,同时确保弹出内容的所有层级都没有白色背景:

<materialDesign:PopupBox StaysOpen="False" PlacementMode="BottomAndAlignCentres"
                         AllowsTransparency="True">
    <!-- 你的内容,确保ScrollViewer、ListBox等背景已设置为深色 -->
</materialDesign:PopupBox>

一般方法一就能解决问题,若仍有残留边框,用方法二直接覆盖内部边框样式即可彻底清除。

内容的提问来源于stack exchange,提问作者Harry Phan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 07:18:28