如何在WPF中将样式应用于Window Control?
我正在为App.xaml中的Window设置样式,如下所示:
<Application x:Class="MusicRepo_Importer.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib" StartupUri="TestMaster.xaml"> <Application.Resources> <Style TargetType="Window"> <Setter Property="WindowStyle" Value="None"></Setter> </Style> </Application.Resources> </Application> 我基本上希望每个Window都将其WindowStyle的属性值设置为None(删除默认的Windows框架和边框);但它没有用. 我在这里想念的是什么?
我相信你必须将样式命名并将其应用于每个窗口,如下所示.
在app.xaml / resources .. <Style x:Key="MyWindowStyle" TargetType="Window"> <Setter Property="WindowStyle" Value="None"></Setter> </Style> 然后在window.xaml .. <Window x:Class="MusicRepo_Importer.MyWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" Title="MyStyledWindow" Style="{StaticResource MyWindowStyle}"> 这应该可行,但只是在资源中应用具有TargetType for Window的样式将不会强制Window使用该样式,尽管它似乎适用于其他元素. 编辑:
来自问题:How to set default WPF Window Style in app.xaml? 回答问题的人对从具有应用样式的基本窗口继承有一个有趣的想法. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows-phone-8.1 – Windows Phone 8.1应用程序中的部署错
- windows-phone-7 – 如何在窗口电话7的列表框中应用备用行样
- Windows CMD命令大全
- Windows10安装Debug
- winapi – 如何检测应用程序所需的DLL?
- .net – 32位和64位MS Windows上Int64和Int32之间的实际性能
- windows-server-2008 – 当dc关闭时,用户是否可以在域网络上
- windows – 在IIS下运行SVN存储库
- windows – 创建一个目录并通过发出一个IRP来获取句柄
- 如果不是交互式的,Microsoft Access VBA的mySQL查询会失败?