How to use default styles for controls as base for custom styles without copying #708
-
For controls from <Style
x:Key="NoSpellCheckTextBoxStyle"
BasedOn="{StaticResource DefaultTextBoxStyle}"
TargetType="TextBox">
<Setter Property="IsSpellCheckEnabled" Value="False" />
</Style> How can we use styles from this library without copying the default style into our resources first? To my knowledge this does not work: <Style
x:Key="MyHeaderedContentControlStyle"
BasedOn="{StaticResource DefaultHeaderedContentControlStyle}"
TargetType="wuic:HeaderedContentControl">
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="IsTabStop" Value="False" />
</Style> While DefaultHeaderedContentControlStyle is a valid style from this library, using it like this crashes when trying to load a control with the custom style. I guess we can agree that simply copying styles is not the way to approach this, because then we would have to track all changes done to the default style and reapply them when necessary. Is it possible for this library to expose the styles like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You need to merge the resource file. App.xaml <Application
x:Class="WinUIDemoApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUIDemoApp">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
<ResourceDictionary Source="ms-appx:///CommunityToolkit.WinUI.Controls.HeaderedControls/HeaderedContentControl/HeaderedContentControl.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
</ResourceDictionary>
</Application.Resources>
</Application> |
Beta Was this translation helpful? Give feedback.
You need to merge the resource file.
App.xaml