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

寻求创建/替换自定义控件+Border,复刻VS/dnSpy式标题栏及蓝色边框

Hey there! Let's break down how to replicate that Visual Studio/dnSpy-style title bar, 1px blue border, and even the Wallpaper Engine-like blue shadow for your app.

Replicating Visual Studio/dnSpy Style Title Bar & Custom Window Effects

First, Understanding dnSpy's Title Bar Approach

Yep, dnSpy uses the same custom title bar pattern as Visual Studio—most likely built on WPF (since dnSpy is a WPF-based tool). I’ll focus on WPF first, but I’ll also touch on a WinForms alternative if that’s your stack.

WPF Implementation Steps

  • Disable Default Window Chrome: Start by turning off the standard window frame with WindowStyle="None" and AllowsTransparency="True". This lets you build a fully custom title bar.
    • Use the WindowChrome class (from System.Windows.Shell) to keep native window behaviors like dragging and resizing. Here’s a quick snippet to set this up:
      <Window.WindowChrome>
          <WindowChrome GlassFrameThickness="0" CaptionHeight="32" ResizeBorderThickness="4" />
      </Window.WindowChrome>
      
    • Build your own title bar: Add minimize/maximize/close buttons that match VS’s styling—use XAML styles to define hover states, background colors (match VS’s dark/light theme tones), and icon placement.
  • 1px Blue Border: Wrap your entire window content in a Border element as the outermost container. Set BorderThickness="1" and BorderBrush="#0078D4" (VS’s default accent blue) to get that sharp 1px edge right at the window’s edge.

WinForms Alternative

If you’re working with WinForms, you’ll need to hook into Windows API calls to customize the non-client area:

  • Use WM_NCCALCSIZE and WM_NCPAINT messages to draw your custom title bar and the 1px blue border directly.
  • Create custom button controls for minimize/maximize/close that mimic VS’s look, handling hover and click states manually.

Adding Wallpaper Engine-Style Tinted Blue Shadow

Wallpaper Engine’s shadow is a custom drop shadow with a blue tint. Here’s how to replicate this in WPF:

  • Add a DropShadowEffect to your outer border (the one with the blue border). Adjust the color, blur radius, and opacity to match the subtle blue shadow effect:
    <Border BorderThickness="1" BorderBrush="#0078D4">
        <Border.Effect>
            <DropShadowEffect Color="#0078D4" BlurRadius="10" ShadowDepth="2" Opacity="0.4" />
        </Border.Effect>
        <!-- Your window content goes here -->
    </Border>
    
  • For WinForms, you’ll need to use Windows API functions like CreateRoundRectRgn and DrawShadow, or leverage a third-party library to render the tinted shadow properly (since WinForms’ built-in shadow doesn’t support color tinting).

Pro Tips for a Polished Result

  • Theme Support: VS and dnSpy switch between light/dark themes, so use dynamic resources for colors in your styles to make theme switching seamless.
  • Windows Version Compatibility: Test on Windows 10 and 11—Windows 11 has rounded window corners, so you might need to adjust your border and shadow to account for that if you want a consistent look.
  • Resizing Grip: When using custom window chrome, add invisible grip areas on the window edges or rely on WindowChrome’s ResizeBorderThickness to ensure users can resize the window easily.

I know it’s tough to find a complete guide for this exact setup, but breaking it into these small parts should help you piece it together. Let me know if you need more specific code snippets for any step!

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 06:51:13