我有一个使用自定义样式库的应用程序,这些样式完全改变了应用程序的外观和感觉,但是我有一个需要使用默认窗口样式的表单,这是我遇到麻烦的地方
如何使这个表单忽略这些样式,以便它使用默认的窗口样式?
以下是我在App.Xmal文件中使用的代码,用于在整个应用程序中使用该样式。没有其他代码用于设置样式,只需创建一个按钮,例如它的风格很好。
提前感谢您的帮助。
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/location;component/file" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
答案 0 :(得分:0)
我已经通过将项目样式设置为null来解决了这个问题,这样就摆脱了我之前的风格。
我已将它们放在资源文件中并在我的表单中引用它。
这就是我所做的
内部表格
<Window.Resources>
<ResourceDictionary
Source="Resources/NullStyles.xaml">
</ResourceDictionary>
</Window.Resources>
内幕文件
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
This can be used to remove any styles from an item and its child items unless the childs style is explicitly set
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-->
<Style TargetType="AccessText"/>
<Style TargetType="AdornedElementPlaceholder"/>
<Style TargetType="Adorner"/>
<Style TargetType="AdornerDecorator"/>
<Style TargetType="AdornerLayer"/>
<Style TargetType="AnchoredBlock"/>
<Style TargetType="Block"/>
<Style TargetType="BlockUIContainer"/>
<Style TargetType="Bold"/>
<Style TargetType="Border"/>
<Style TargetType="BulletDecorator"/>
<Style TargetType="Button"/>
<Style TargetType="ButtonBase"/>
<Style TargetType="Calendar"/>
<Style TargetType="CalendarButton"/>
<Style TargetType="CalendarDayButton"/>
<Style TargetType="CalendarItem"/>
<Style TargetType="Canvas"/>
<Style TargetType="CheckBox"/>
<Style TargetType="ColumnDefinition"/>
<Style TargetType="ComboBox"/>
<Style TargetType="ComboBoxItem"/>
<Style TargetType="ContentControl"/>
<Style TargetType="ContentPresenter"/>
<Style TargetType="ContextMenu"/>
<Style TargetType="Control"/>
<Style TargetType="DataGrid"/>
<Style TargetType="DataGridCell"/>
<Style TargetType="DataGridCellsPanel"/>
<Style TargetType="DataGridCellsPresenter"/>
<Style TargetType="DataGridColumnHeader"/>
<Style TargetType="DataGridColumnHeadersPresenter"/>
<Style TargetType="DataGridDetailsPresenter"/>
<Style TargetType="DataGridRow"/>
<Style TargetType="DataGridRowHeader"/>
<Style TargetType="DataGridRowsPresenter"/>
<Style TargetType="DatePicker"/>
<Style TargetType="DatePickerTextBox"/>
<Style TargetType="Decorator"/>
<Style TargetType="DefinitionBase"/>
<Style TargetType="DockPanel"/>
<Style TargetType="DocumentPageView"/>
<Style TargetType="DocumentReference"/>
<Style TargetType="DocumentViewer"/>
<Style TargetType="DocumentViewerBase"/>
<Style TargetType="Ellipse"/>
<Style TargetType="Expander"/>
<Style TargetType="Figure"/>
<Style TargetType="FixedDocument"/>
<Style TargetType="FixedDocumentSequence"/>
<Style TargetType="FixedPage"/>
<Style TargetType="Floater"/>
<Style TargetType="FlowDocument"/>
<Style TargetType="FlowDocumentPageViewer"/>
<Style TargetType="FlowDocumentReader"/>
<Style TargetType="FlowDocumentScrollViewer"/>
<Style TargetType="Frame"/>
<Style TargetType="FrameworkContentElement"/>
<Style TargetType="FrameworkElement"/>
<Style TargetType="Glyphs"/>
<Style TargetType="Grid"/>
<Style TargetType="GridSplitter"/>
<Style TargetType="GridViewColumnHeader"/>
<Style TargetType="GridViewHeaderRowPresenter"/>
<Style TargetType="GridViewRowPresenter"/>
<Style TargetType="GridViewRowPresenterBase"/>
<Style TargetType="GroupBox"/>
<Style TargetType="GroupItem"/>
<Style TargetType="HeaderedContentControl"/>
<Style TargetType="HeaderedItemsControl"/>
<Style TargetType="Hyperlink"/>
<Style TargetType="Image"/>
<Style TargetType="InkCanvas"/>
<Style TargetType="InkPresenter"/>
<Style TargetType="Inline"/>
<Style TargetType="InlineUIContainer"/>
<Style TargetType="Italic"/>
<Style TargetType="ItemsControl"/>
<Style TargetType="ItemsPresenter"/>
<Style TargetType="Label"/>
<Style TargetType="Line"/>
<Style TargetType="LineBreak"/>
<Style TargetType="List"/>
<Style TargetType="ListBox"/>
<Style TargetType="ListBoxItem"/>
<Style TargetType="ListItem"/>
<Style TargetType="ListView"/>
<Style TargetType="ListViewItem"/>
<Style TargetType="MediaElement"/>
<Style TargetType="Menu"/>
<Style TargetType="MenuBase"/>
<Style TargetType="MenuItem"/>
<Style TargetType="MultiSelector"/>
<Style TargetType="NavigationWindow"/>
<Style TargetType="Page"/>
<Style TargetType="PageContent"/>
<Style TargetType="PageFunctionBase"/>
<Style TargetType="Panel"/>
<Style TargetType="Paragraph"/>
<Style TargetType="PasswordBox"/>
<Style TargetType="Path"/>
<Style TargetType="Polygon"/>
<Style TargetType="Polyline"/>
<Style TargetType="Popup"/>
<Style TargetType="ProgressBar"/>
<Style TargetType="RadioButton"/>
<Style TargetType="RangeBase"/>
<Style TargetType="Rectangle"/>
<Style TargetType="RepeatButton"/>
<Style TargetType="ResizeGrip"/>
<Style TargetType="RichTextBox"/>
<Style TargetType="RowDefinition"/>
<Style TargetType="Run"/>
<Style TargetType="ScrollBar"/>
<Style TargetType="ScrollContentPresenter"/>
<Style TargetType="ScrollViewer"/>
<Style TargetType="Section"/>
<Style TargetType="SelectiveScrollingGrid"/>
<Style TargetType="Selector"/>
<Style TargetType="Separator"/>
<Style TargetType="Shape"/>
<Style TargetType="Slider"/>
<Style TargetType="Span"/>
<Style TargetType="StackPanel"/>
<Style TargetType="StatusBar"/>
<Style TargetType="StatusBarItem"/>
<Style TargetType="StickyNoteControl"/>
<Style TargetType="TabControl"/>
<Style TargetType="TabItem"/>
<Style TargetType="TabPanel"/>
<Style TargetType="Table"/>
<Style TargetType="TableCell"/>
<Style TargetType="TableColumn"/>
<Style TargetType="TableRow"/>
<Style TargetType="TableRowGroup"/>
<Style TargetType="TextBlock"/>
<Style TargetType="TextBox"/>
<Style TargetType="TextBoxBase"/>
<Style TargetType="TextElement"/>
<Style TargetType="Thumb"/>
<Style TargetType="TickBar"/>
<Style TargetType="ToggleButton"/>
<Style TargetType="ToolBar"/>
<Style TargetType="ToolBarOverflowPanel"/>
<Style TargetType="ToolBarPanel"/>
<Style TargetType="ToolBarTray"/>
<Style TargetType="ToolTip"/>
<Style TargetType="Track"/>
<Style TargetType="TreeView"/>
<Style TargetType="TreeViewItem"/>
<Style TargetType="Underline"/>
<Style TargetType="UniformGrid"/>
<Style TargetType="UserControl"/>
<Style TargetType="Viewbox"/>
<Style TargetType="Viewport3D"/>
<Style TargetType="VirtualizingPanel"/>
<Style TargetType="VirtualizingStackPanel"/>
<Style TargetType="WebBrowser"/>
<Style TargetType="Window"/>
<Style TargetType="WrapPanel"/>
</ResourceDictionary>