WPFDevelopersOrg / WPFDevelopers

🎉 Welcome to follow the "WPFDevelopers" public account! This is a sample project we share daily, covering WPF's basic controls and custom control libraries. The project will be continuously updated, welcome to give us ⭐️
MIT License
1.5k stars 240 forks source link

ScreenCapture控件建议 #68

Closed chen2well closed 8 months ago

chen2well commented 11 months ago

当加载资源字典无法写在App.xaml时,写在Window.Resources时 ScreenCapture及ScreenCut无法正常使用

yanjinhuagood commented 9 months ago

update in ScreenCapture 问题已再此提交修复。

yanjinhuagood commented 9 months ago

1.引入WD的资源文件

<Window>
  <Window.Resources>
       <ResourceDictionary.MergedDictionaries>
           <ResourceDictionary Source="pack://application:,,,/WPFDevelopers;component/Themes/Light.Blue.xaml"/>
           <!--需要注意 wd:Resources 必须在配色主题后,Theme="Dark" 为黑色皮肤-->
           <wd:Resources Theme="Light"/>
           <ResourceDictionary Source="pack://application:,,,/WPFDevelopers;component/Themes/Theme.xaml"/>
       </ResourceDictionary.MergedDictionaries>
  </Window.Resources>
  <Button Content="ScreenCapture" VerticalAlignment="Top" HorizontalAlignment="Center" Click="Button_Click" Margin="0,10"/>
</Window>

2.在弹出截图控件时将资源传入

private void Button_Click(object sender, RoutedEventArgs e)
{
  Dispatcher.Invoke(new Action(delegate
  {
     ScreenCapture screenCapturer = new ScreenCapture(resources: this.Resources);
     screenCapturer.Capture();
  }));
}