Microsoft-ui-xaml: Override AutoSuggestBox TextBoxStyle with the DefaultTextBoxStyle

Created on 19 May 2020  路  5Comments  路  Source: microsoft/microsoft-ui-xaml

The issue is so simple and simple to fix also But unfortunately I can't test because I'm getting this issue when trying to debug the code
Type 'StaticResource' used after '{' must be a Markup Extension. Error code 0x03e9.
The main issue is that the AutoSuggestBox style is different from TextBox
image
I think simply 2 or 3 lines of Xaml code can solve this issue simply.

Most helpful comment

Afaik there is no good way to exclude styles. If the old style of a control is not causing this issues, you could get the old style and add it to your application (or page) resources.

Regarding merged dictionaries:

In the XAML Controls Gallery, we do the following to load the WinUI resource dictionary alongside another dictionary:

<Application>
            <ResourceDictionary.MergedDictionaries>
                <!-- Custom dictionary -->
                <local:ItemTemplates />
                <!-- WinUI styles and resources -->
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
            </ResourceDictionary.MergedDictionaries>
</Application>

All 5 comments

I am not entirely sure what the issue here is. On my machine the TextBox and the AutoSuggestBox look quite the same except for the quereybutton:

image

image

uh You're right @chingucoding
Is there any way to exclude any of the styles in Microsoft.Xaml.UI
Seems this style https://github.com/microsoft/microsoft-ui-xaml/blob/master/dev/CommonStyles/MediaTransportControls_themeresources.xaml
is causing this issue on mobile:
https://github.com/microsoft/microsoft-ui-xaml/issues/2438

And another question is there any way to reference the MS.UI.Xaml styles in my resource dictionary for example this way
<Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="ms-appx:///Microsoft.UI.Xaml/Styles.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources>

or no?
Thanks for your help anyhow

Afaik there is no good way to exclude styles. If the old style of a control is not causing this issues, you could get the old style and add it to your application (or page) resources.

Regarding merged dictionaries:

In the XAML Controls Gallery, we do the following to load the WinUI resource dictionary alongside another dictionary:

<Application>
            <ResourceDictionary.MergedDictionaries>
                <!-- Custom dictionary -->
                <local:ItemTemplates />
                <!-- WinUI styles and resources -->
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls"/>
            </ResourceDictionary.MergedDictionaries>
</Application>

Thanks really for your helps @chingucoding

Happy that I could help you :)

Was this page helpful?
0 / 5 - 0 ratings