简体   繁体   English

WPF NavigationWindow中的OverrideDefaultStyle吗?

[英]OverrideDefaultStyle in WPF NavigationWindow?

When creating a Navigation Application in WPF, How can I create a custom style and layout for the window? 在WPF中创建导航应用程序时,如何为窗口创建自定义样式和布局? Is this possible? 这可能吗? Say for instance, adding a panel along the side of the window with links to all the pages in the application. 例如,在窗口的侧面添加一个面板,该面板带有指向应用程序中所有页面的链接。 When I try add controls/content to the NavigationWindow, I get the following message: 当我尝试将控件/内容添加到NavigationWindow时,出现以下消息:

"The type 'NavigationWindow' does not support direct content." “类型'NavigationWindow'不支持直接内容。”

Thanks 谢谢

I'm not sure I understand the suggestion of starting with a normal Window, adding a frame and then enabling the ShowsNavigationUI property. 我不确定我是否理解从普通Window开始,添加框架并启用ShowsNavigationUI属性的建议。 This is essentially what the NavigationWindow is; 本质上,这就是NavigationWindow。 you might as well start there. 您最好从那里开始。 The Forward/Backward buttons that show up in the Frame will appear as part of the content window. 框架中显示的前进/后退按钮将显示为内容窗口的一部分。 Yes, it will work, but it will also appear very strange as most users are going to want to see the navigation controls in the upper left hand corner of your frame. 是的,它可以工作,但是由于大多数用户都想查看框架左上角的导航控件,因此它也会显得很奇怪。

There are three options available. 共有三个选项。 The first one is to just re-skin the NavigationWindow. 第一个是只重新设置NavigationWindow的外观。 You can find the original WPF templates for the NavigationWindow on line. 您可以在线找到NavigationWindow的原始WPF模板。 If you have trouble, I can find a link for you. 如果您遇到问题,我可以为您找到一个链接。 You can use these as a starting point and add your own controls to the frame. 您可以将它们用作起点并将自己的控件添加到框架。 The most important part of creating your own NavigationWindow template is to include a ContentPresenter as a part with the name "PART_WinNavCP". 创建自己的NavigationWindow模板最重要的部分是将ContentPresenter作为名称包括“ PART_WinNavCP”的一部分。

The second option is to use Expression Blend to extract the elements of the NavigationWindow for you. 第二个选项是使用Expression Blend为您提取NavigationWindow的元素。 But again, you'll need to assembly all the parts once you've reverse engineered them. 但是同样,一旦对它们进行反向工程,就需要组装所有零件。

The third option is the one that I've put together. 第三种选择是我提出的选择。 It was created by me because I ran into the same limitations you ran (are running) into. 它是由我创建的,因为我遇到了与运行(运行)相同的限制。 If you want to focus on creating a real Navigation-style interface without trying to reskin the entire control, please have a look at: 如果您想专注于创建一个真正的导航样式的界面而又不尝试重新调整整个控件的外观,请查看:

http://www.teraque.com/products/explorer-chrome-suite/ http://www.teraque.com/products/explorer-chrome-suite/

I've provided a free demo. 我提供了一个免费的演示。 Take it out for a spin. 旋转一下。 Even if you don't want to purchase the product, I can give you pointers if this is what you are trying to accomplish. 即使您不想购买该产品,如果您要达到目的,我也可以为您提供指导。

Sincerely, 真诚的

Donald Roy Airey 唐纳德·罗伊·艾利

donald.roy.airey@teraque.com donald.roy.airey@teraque.com

To customize the host window in a navigation-style app, just make yourself a normal WPF application, with a normal Window, and drop a Frame control into that window. 要在导航样式的应用程序中自定义宿主窗口,只需使自己成为具有常规Window的普通WPF应用程序,然后将Frame控件放入该窗口即可。 Set the Frame's Source to the page you want the app to start with and it'll behave just like your standard navigation app, except you'll have the ability to customize the window with other controls etc. 将“框架的源代码”设置为您希望应用程序启动的页面,它的行为就像您的标准导航应用程序一样,不同之处在于您可以使用其他控件等自定义窗口。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM