小编Pat*_*ick的帖子

具有模糊效果的分层窗口

我真的很喜欢例如在 iOS 中可以看到的效果,它基本上看起来像是在当前视图之上绘制的图层,模糊了视觉内容并将其用作背景。有没有办法在 WPF 中实现类似的目标?

IOS

我见过人们主要在窗口级别处理这种模糊/透明度,但我需要在窗口内使用它。

假设这是我的窗口的内容。

<StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
        <Image  Source="pack://application:,,,/Resources/Penguins.jpg"/>
        <Image  Source="pack://application:,,,/Resources/Penguins.jpg"/>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

看起来像

无层

现在我想在上面画一些东西(而不是使用红色背景)模糊它下面的任何东西并将其用作背景,保持它的内容不模糊。

    <DockPanel Margin="15" Background="Red">
        <StackPanel Orientation="Horizontal"  VerticalAlignment="Center" HorizontalAlignment="Center">
            <Label Content="Some label"/>
            <TextBox Width="100" Height="20"/>
        </StackPanel>
    </DockPanel>
Run Code Online (Sandbox Code Playgroud)

模糊层

c# wpf blurry

5
推荐指数
1
解决办法
3537
查看次数

如何连接字符?

我的升 C 调技能很基础,但我偶然发现了“连接”部分

当我连接以下代码时,它可以正常工作:

string a, b, c;
          a = "Bon";
          b = "jour";
          c = a + b;
          Console.WriteLine(c);
          Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)

控制台结果 = Bonjour

现在我尝试对 char 做同样的事情。

 char c1, c2, c3;
          c1 = 'B';
          c2 = 'j';
          c3 = c1 + c2;
          Console.WriteLine(c3);
          Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)

错误:无法将类型“int”隐式转换为“char”。存在显式转换(您是否缺少强制转换?)

这就是我尝试的,因为我学会了如何投射。

 char c1, c2, c3;
          c1 = 'B';
          c2 = 'j';
          c3 = (char) c1 + c2;
          Console.WriteLine(c3);
          Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)

同样的错误。

这并不是说我需要连接2个字符,我只是在学习。我只是不明白为什么这个演员阵容不可能。

提前致谢。

c# string concatenation char

5
推荐指数
1
解决办法
2万
查看次数

如何在PropertyGrid中插入EventsTab?

这是交易,我有一些集合要插入到验证类中,我试图让它能够插入到Visual Studio的编辑器IDE中并解释所有上下文(如果还不够,请问我)我想要PropertyGrid以显示EventsTab这样在Visual Studio的IDEPropertyGrid VS Editor中的EventsTab

但问题是我已经检查了winforms源代码并且我能理解我已经发现为了插入Button for EventsTab我们必须调用ShowEventsButton(true)PropertyGrid的私有方法但是不能工作(用反射调用它)

那么到目前为止我尝试了什么......

  • Caliing AddRefTab使用参数传递EventsTab(私有方法)
  • 使用true参数调用SetupToolbar(私有方法)
  • 调用RefreshTabs
  • 将所有TooltipItens设置为Visible
  • 调用ShowEventsButton(true)

编辑

我在这个方案中有两个类,其中一个是Validation类,它继承自IValidation接口,它有我想在propertyGrid中显示的事件,另一个类是一个ControlValidator,它派生自一个组件并且有一个列表验证

编辑2

更具体地说,我想要完成的是在这个CollectionEditor中使用CollectionEditor(用于编辑DataGridView的列的相同窗口)我想让它在PropertyGrid中显示EventsTab(实际上我想要制作它)它与VisualStudio IDE的PropertyTab完全相同,但我不在那部分但是,所以我想要显示的事件和属性是ControlValidator(组件)的List/Collection

让我试着说清楚一点 类图 正如您所看到的,Control Validator有一个IValidation接口的集合,它是组件所以它应该并且正在这样工作 ControlValidator应该正常工作 你可以看到它没有在IDE中显示事件选项卡,因为它没有任何事件,但如果你双击controlValidator的Validations属性,它会打开CollectionEditor,其中有一个PropertyGrid CollectionEditor 作为一个PropertyGrid,我试图让它显示eventsTab(我无法以我在其中列出的任何方式显示它)

.net c# collections visual-studio winforms

2
推荐指数
1
解决办法
866
查看次数

标签 统计

c# ×3

.net ×1

blurry ×1

char ×1

collections ×1

concatenation ×1

string ×1

visual-studio ×1

winforms ×1

wpf ×1