FocusVisualStyle 在 wpf 自定义控件中不起作用

moh*_*avi 3 c# wpf custom-controls

我在WPF中设计了一些自定义控件,如CustomWindow、CustomButton等,当我在其他项目中使用这些控件时,FocusVisualStyle不适用于所有控件(WPF内置控件和我的自定义控件)。我该如何解决这个问题?

小智 5

如果使用Custom Window,窗体Window Style中的ContentPresenter外层必须添加AdornerDecorator。窗口内的控件将显示 FocusVisualStyle。

<Style TargetType="xxxWindow">
    ...
    <AdornerDecorator>
        <ContentPresenter/>
    </AdornerDecorator>
    ...
</Style>
Run Code Online (Sandbox Code Playgroud)