.net - 在 WPF 中为 NestedClass 声明样式 TargetType

标签 .net wpf xaml styles targettype

我有 MyClass 类。
我声明

<Style TargetType="local:MyClass"></Style>

没问题。

我有 MyClass.MyNestedClass(公共(public))类(class)。

我声明...?

最佳答案

你需要使用+来分隔外部类名和嵌套类名:

<Style TargetType="local:MyClass+MyNestedClass"></Style>

关于.net - 在 WPF 中为 NestedClass 声明样式 TargetType,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4277508/

相关文章:

c# - 将 XDocument 解析为 Dictionary<string, string>

WPF 菜单项左对齐?

c# - WPF ResizeMode 改变窗口大小

c# - 按住右键单击与 Manipulation 事件冲突

c# - 将 ListBox 的 ItemsSource 设置为其包含类的属性

.net - 如何从服务本身内部获取Windows服务的名称

c# - 有没有一种方法可以序列化实现 ICollection 的类的公共(public)属性

c# - 在我的场景中抽象和 protected 之间有什么区别 - C#

WPF : Chainging another control's property in some control's Trigger

c# - UWP 中的弱事件模式