Closed lucas-yotsui closed 3 months ago
<AutoSuggestBox>
<AutoSuggestBox.TextBoxStyle>
<Style TargetType="TextBox">
<Setter Property="IsSpellCheckEnabled" Value="False" />
</Style>
</AutoSuggestBox.TextBoxStyle>
</AutoSuggestBox>
<AutoSuggestBox> <AutoSuggestBox.TextBoxStyle> <Style TargetType="TextBox"> <Setter Property="IsSpellCheckEnabled" Value="False" /> </Style> </AutoSuggestBox.TextBoxStyle> </AutoSuggestBox>
Sorry guys, clearly it was a skill issue here, as I had no idea this was even possible. However, I noticed that when I did this my query icon disapperared, is there any way I can keep it while doing this? The icon is actually an important part of my design
<AutoSuggestBox QueryIcon="Find">
<AutoSuggestBox.TextBoxStyle>
<Style BasedOn="{StaticResource AutoSuggestBoxTextBoxStyle}" TargetType="TextBox">
<Setter Property="IsSpellCheckEnabled" Value="False" />
</Style>
</AutoSuggestBox.TextBoxStyle>
</AutoSuggestBox>
FYI, not all MUXC (Microsoft.UI.XAML.Controls) controls have properties that allow you to set styles for internal parts of the control like AutoSuggestBox.TextBoxStyle
.
Using BasedOn
here is stating the style should inherit everything found in the default style AutoSuggestBoxTextBoxStyle
, which can be found in your generic.xaml
file, which is typically located here-ish:
C:\Users\<username>\.nuget\packages\microsoft.windowsappsdk\<wasdkversion>\lib\<platform>\Microsoft.WinUI\Themes
In my case:
C:\Users\kmgal\.nuget\packages\microsoft.windowsappsdk\1.4.231219000\lib\net6.0-windows10.0.18362.0\Microsoft.WinUI\Themes
It is a 36K line file that contains default styles and named 'light-weight' styles to set some individual values. You can also copy+paste entire styles to edit and "reskin" MUXC controls without starting from scratch.
<AutoSuggestBox QueryIcon="Find"> <AutoSuggestBox.TextBoxStyle> <Style BasedOn="{StaticResource AutoSuggestBoxTextBoxStyle}" TargetType="TextBox"> <Setter Property="IsSpellCheckEnabled" Value="False" /> </Style> </AutoSuggestBox.TextBoxStyle> </AutoSuggestBox>
Thank you so much, this worked perfectly!
Clearly I have much to learn on XAML and WinUI I'm general, thanks for the tips and the solution!
Describe the bug
I'm new to WinUI so I don't have a lot of knowledge on how all this stuff works, why some things were implemented the way they were, etc, etc. But I have noticed that the AutoSuggestBox elements do not have any way to disable the spell checking, which in my opinion does not make any sense! The text input by the user and the options shown are not always considered grammarly correct.
Take for example the application I'm currently developing, in which we have an AutoSuggestBox used for a group of names that are all acronyms. those are perfectly valid names for our application, however I keep getting red squiggly lines every time I use it.
I believe this problem can be easily solved by giving this element a IsSpellCheckEnabled field just like a regular TextBox field.
(Sorry if my english is not the best, it isn't my first language ¯\(ツ)/¯ )
Steps to reproduce the bug
I don't think any code sample is really needed here, just implement a simple AutoSuggestBox and input it with anything not grammarly correct.
Expected behavior
No response
Screenshots
No response
NuGet package version
None
Windows version
Windows 11 (22H2): Build 22621
Additional context
No response