简体   繁体   English

如何模仿用于WPF控件的默认模板?

[英]How do I mimic the default template used for a WPF control?

I've got an area (control of type Border) on my window with content that relates to the selected object in a nearby GridView within a ListView. 我的窗口上有一个区域(类型为Border的控件),其内容与ListView附近的GridView中的选定对象相关。

I want the style of that area to match the style (borders and gradients) of the selected ListViewItem. 我希望该区域的样式与所选ListViewItem的样式(边界和渐变)匹配。 The look will depend on the user's operating system and its theme. 外观将取决于用户的操作系统及其主题。

How do I give my box the same look as a list item? 如何给我的盒子和列表项一样的外观?

Mock-up: 小样:

在此处输入图片说明

I don't think I fully understand but my guess is that you are talking about the default ListBox selection brush? 我想我不太了解,但是我猜您正在谈论默认的ListBox选择笔刷吗?

That resource is called 该资源称为

{x:Static SystemColors.HighlightBrushKey}

That is the Blue background you show in your mock up. 那就是您在模型中显示的蓝色背景。 If you want to also set the foreground color that is: 如果还要设置前景色,则:

{x:Static SystemColors.HighlightTextBrushKey}

Those two resources will give the system setting for the given user / OS / theme for selection. 这两个资源将为给定的用户/ OS /主题提供系统设置供选择。 Is that what you are after? 那是你的追求吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获得WPF控件来模仿禁用状态? - How do I get WPF control to mimic the disabled state? 在WPF中,如何为自定义控件提供在设计模式下使用的默认样式? - In WPF, how do I give my custom control a default style to be used in Design Mode? 如何使用默认值填充模板中使用的控件? - How to populate the control that is used in the template with default value? 如何在WPF中为控件模板的一部分制作动画? - How do I animate part of a control's template in WPF? 如何为WPF中的自定义控件提供两个默认模板? - How do I provide two default templates for a Custom Control in WPF? WPF控制模板触发器如何工作? - How do wpf control template triggers work? 如何在WPF中使用控制模板在样式上施加默认样式 - How to impose default style on styles with Control Template in WPF 如何在XAML中创建具有以下要求的WPF CheckBox控件模板? - How do I create a WPF CheckBox control template in XAML with the following requirements? 在WPF中,如何在控制模板中获取命令以绑定到父级中的属性? - In WPF, how do I get a command in a Control Template to bind to a property in a parent? WPF图表控件默认存在或我必须进行外部下载? - WPF chart control exists by default or I have to do an external download?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM