-
Describe the bugMuch has changed in WinUI-3 styles since WPF 4.5, but I cannot find anything written on how to present a user with error text just below the input field. Specifically wishing to provide several fields on a control, but show the error for each separately and underneath 2 input TextBoxes on a form- just like this hacked image from the WinUI 3 gallery: The WinUI 3 gallery does not yet show any detail under InputValidation so no examples there. The default styles for TextBox (generic.xaml) do show an ErrorPresenter in the Visual States but the content is currently blank unlike the DescriptionPresenter as in this code below:
There are also VisualStates in generic.xaml of Can someone tell me how best to do this at current time. I am using Community Toolkit with MVVM and ObservableValidator. Validation errors are currently a private field of type dictionary - do I have to extract public error message for each input field so I can bind a text field to them - seems a lot of work - am I missing the point of these new WinUI 3 controls, or am I simply waiting for something that is not there yet? Steps to reproduce the bugDocumentation on WinUI 3 xaml validation is missing Expected behaviorLove to see an example or documentation on how to display messages in XAML from INotifyDataErrorInfo interface ScreenshotsNo response NuGet package versionWinUI 3 - Windows App SDK 1.1.2 Windows app type
Device form factorDesktop Windows versionWindows 10 (21H2): Build 19044 Additional contextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 15 comments 18 replies
-
Ran into this as well man. Currently im just populating a collection with the GetErrors method and showing them in a listview, not ideal though. There is a parameter for property name on the GetErrors method as well so I guess could have a user control with a textblock that you put under each control on the xaml and it could look up the geterrors to set the text. But I havent figured out the MVVM approach to that yet. |
Beta Was this translation helpful? Give feedback.
-
Any new information on this one? |
Beta Was this translation helpful? Give feedback.
-
How can be notified an error during mainWindow initialization in desktop app? |
Beta Was this translation helpful? Give feedback.
-
Any news? |
Beta Was this translation helpful? Give feedback.
-
Any news? |
Beta Was this translation helpful? Give feedback.
-
Still greyed out |
Beta Was this translation helpful? Give feedback.
-
I also run into that problem, any news or plans for this? |
Beta Was this translation helpful? Give feedback.
-
i think that this issue can be fixed migrating code to avalonia ui. the added bonus is an avalonia xaml designer plugin for visual studio that microsoft refused to make for winui |
Beta Was this translation helpful? Give feedback.
-
+1 for this discussion. Totally weird that this elementary feature is not available in 2023 newest Microsoft application framework! Looking back in history to origin of Windows Forms highlighting the word „forms“ in it - conceptional build for input forms. Nowadays it seems animations and transparency is more important than business cases 😔 |
Beta Was this translation helpful? Give feedback.
-
What's the problem? If you need to place a text block, you can just... place a text block. Is this a task for which framework support is needed? |
Beta Was this translation helpful? Give feedback.
-
omikhailov, we are speaking about error notification during initialization. There is no window to place a textbox. If you could place a textbox would be present a window and a XamlRoot. So you ahve no problem to use a ContentDialog. |
Beta Was this translation helpful? Give feedback.
-
I recently saw this discussion and decided to build a quick sample with |
Beta Was this translation helpful? Give feedback.
-
I can see you have selected an answer, but I still find it cumbersome to find a good solution for this, I am also using MVVM Toolkit in WinUI3 App and showing validation messages directly at the control (for example Textbox) is a common use case, still there seems to be hardly any featured approach on how to implement this task with ObservableValidator, I do not want to implement this whole logic from scratch defining dozens of styles and templates, so the easiest way was for me was to temporarily aggregate all the ValidationErrors into a Listbox but this is everything but optimal.. |
Beta Was this translation helpful? Give feedback.
-
The solution posted above is admirable but it is not a substitute for a legitimate validation framework, which would need to be built into the binding mechanism. The binding mechanism, if the binding source property's parent object implements |
Beta Was this translation helpful? Give feedback.
-
What's going on with WinUI? Still no solution exists for framework integrated Input Validation from Microsoft yet! Why? The latest version of WinUI 3 Gallery App still have the readonly menu item "Basic Input > InputValidation" in sidebar!
This is ridiculous. Is WinUI 3 dead even before it lived? |
Beta Was this translation helpful? Give feedback.
I recently saw this discussion and decided to build a quick sample with
TextBox
- it could definitely use support from WinUI, having an equivalent ofINotifyDataErrorInfo
(and maybe a new interface for controls that support input validation) would make this scenario a whole lot nicer. This solution is not fully polished, I might work on a nicer version of it eventually, but for now it's just a proof of concept with UWP/WinUI 2. Should be easy to port to WinUI 3, it's just a few attached properties and a custom style for the input fields:InputValidation.zip