All Questions
Tagged with validation wpf
1,219 questions
0
votes
0
answers
26
views
WPF DataGrid disabling editing on validation errors
My view has a DataGrid that displays a ObservableCollection<MyViewModel>. To validate the input of MyViewModel properties, I use a ValidationRule that checks all model properties in the Validate ...
0
votes
0
answers
49
views
In WPF app form validation errors not showing up in UI
I'm new to WPF and I need to create a small app in .NET8 that generates text files. In UI I want to have two mandatory fields, one of them accepting only numbers greater than 0. I used fluent ...
0
votes
1
answer
45
views
How to pass information from the view model to a validation rule
I'm quite new to programming C# and WPF. I have two TextBoxes where I want to validate user input with validation rules:
<TextBox
x:Name="TextBox1">
<TextBox.Text>
...
0
votes
1
answer
119
views
Validation ErrorTemplate shows on `ContentControl` instead of `TextBox`
Problem
I'm trying to generate visual feedback on the result of validating a TextBox input control with the following requirements:
A red box is displayed around the textbox border
Any error messages ...
0
votes
1
answer
273
views
MVVM Toolkit Data Validation and ObservableProperty
I'm working in WPF and using the MVVM community toolkit. Reading the documentation, I understand that I can make validation work by inheriting from ObservableValidator and using this pattern for my ...
-1
votes
1
answer
44
views
How do I use validation to prevent a user from duplicating Datagrid value?
I am trying to figure out how to prevent users from adding or renaming fields in a datagrid, if the value they choose is a duplicate. For example, if there is a directory of Person objects, if someone ...
1
vote
2
answers
70
views
WPF show validation errors under custom button [duplicate]
I am creating a WPF application with the MVVM pattern.
Validation errors are managed by using INotifyDataErrorInfo. The ViewModel implements INotifyDataErrorInfo.
For System.Windows.Controls controls ...
0
votes
1
answer
48
views
Timing problem in WPF data binding in styles
I wanted to have data validation at once in WPF binding so I used PropertyChanged at UpdateSourceTrigger. At the same time I wanted to detect LostFocus, this is the time I modify the DB. Moreover, I ...
0
votes
0
answers
48
views
INotifyDataErrorInfo - Red border doesn't disappear when error is cleared
Please check below a simple project reproducing the issue.
The issue is that the red border (meaning there is an error) remains on my control even though error is cleared.
In a WPF app, I have a "...
-1
votes
1
answer
297
views
WPF TextBox Validation using INotifyDataErrorInfo
I have created a Custom TextBox control, which overrides TextBox. I have it all working perfectly and I also have validation working with an Override of OnTextChanged.
The issue I have now is that the ...
1
vote
0
answers
45
views
WPF - validation adorners do not position correctly when there multiple controls with validation errors
I have a WPF application built with .NET Framework 4.8. I have a viewmodel that implements INotifyDataErrorInfo for validation. In my XAML I am using the default Validation.ErrorTemplate, but I have ...
1
vote
0
answers
56
views
WPF Telerik RadGridView prevents button clicking when cell value is invalid
I have a telerik:RadGridView cell with validation that works as intended; however, in the cases where the cell is invalid, all the buttons on that same window don't respond. I added code to disable my ...
0
votes
1
answer
41
views
ValidationRule with UpdateSourceTrigger=LostFocus not firing when textbox loses focus
I am attempting to implement validation for form data in a WPF application.
View
<StackPanel Orientation="Horizontal" Margin="0 5 0 5">
<TextBlock Style="{...
0
votes
1
answer
235
views
WPF-UserControl with the .NET library FluentValidation
I use WPF with MVVM and for validation the .NET library FluentValidation (https://github.com/FluentValidation).
With a TextBox and a simple validation
RuleFor(x => x.Name).NotEmpty().WithMessage(&...
0
votes
3
answers
6k
views
MVVM Community Toolkit: Using ObservableValidator with non-string properties
I have a WPF application that uses the ObservableValidator to handle validation of properties using data annotations. This works great for string properties. For example:
public class LoginViewModel : ...
-1
votes
1
answer
40
views
Insert same value in textbox 2 times and checking the values are the same WPF
i'm trying to implement a feature of a textbox in wpf so that a value need to be inserted 2 times to be accepted as the value, otherwise i need to show an errore like validation error or so.
I need to ...
0
votes
1
answer
654
views
How do I stop the red border on an empty WPF textbox when bound to a Decimal property?
I have a textbox bound to a nullable decimal property.
<TextBox Text="{Binding DueRent}" Style="{x:Null}" Width="150"/>
public decimal? DueRent { get => ...
0
votes
1
answer
133
views
WPF - ErrorTemplate tooltip showing on the Border but not one the TextBox
I have TextBox controls with a Binding to an integer property. They're like:
<TextBox x:Name="txtInteger"
Grid.Row="2"
Grid.Column="0"
Text=&...
2
votes
1
answer
538
views
WPF Validate custom objects in ViewModel
I am using Mvvm Community Toolkit's ObservableValidator for validating viewmodel properties. When there is some custom object in my view model that is bind to the view, how to validate all of these ...
-3
votes
1
answer
209
views
Why are validation errors not working as expected inside ListBox and ListBoxItem?
I've been trying to implement some error validation in a WPF application, and I've been banging my head for two days on how to do it correctly inside a ListBox. I'm using ObservableValidator and ...
0
votes
0
answers
169
views
wpf - how to use an underlying control's validation template for an user control
I have a user control that consists of a textblock and a textbox and if I validate via INotifyDataErrorInfo the underlying data the whole control gets a red border: How it looks like
I would like to ...
0
votes
1
answer
309
views
How to get the result of a ValidationResult method, inside ViewModel? (True / False)
I have an (part of) XAML file like this
<TextBox.Text>
<Binding Path="MyProperty"
...
0
votes
2
answers
474
views
WPF Can't Remove Red Border from UserControl
I've built a simple login page and when invalid input is detected, a red border is drawn around the usercontrol.
Here is my layout code:
<UserControl x:Class="WPFTest.UI.Views.EmptyLayout&...
0
votes
1
answer
59
views
How can I let my view model know when XAML data validation has failed
I have a form where users set parameters for a numerical process. Each parameter object has a default value.
public double DefaultValue
{
get => _defaultValue;
set
{
...
-2
votes
1
answer
137
views
C# - How to validate data in C1DataGrid?
I have a C1DataGrid with one column and I want to be able to validate the data when I commit a new row in the grid.
So far I tried to throw an exception in the setter of this property.
This validates ...
0
votes
0
answers
70
views
Why does my TextBox dosent work properly, when I want make the border red, if input is invalid?
basiclly the input of the TextBox is an articel number, and if the number is older then 6 Month I want to mark the border of my textbox red. For that I need to get data from an SQL Query btw.
The Code ...
0
votes
1
answer
100
views
WPF Style design TextBox Tooltip
I would like to style the Tooltip of Textboxes which are used for validation. I'm trying to get a rounded corners Tooltip without sucess. How may I get it from ResourceDictonary?
With the code below, ...
1
vote
1
answer
1k
views
WPF - How to validate a form after clicking on a button?
I found this simple example for validating user inputs in WPF. It works fine, but the validation happens after every input change. I would like the validation to happen only when the button is clicked ...
1
vote
1
answer
105
views
Is it possible to change properties on the validation error template in WPF?
I'm using the Validation.ErrorTemplate property in my XAML view to display an icon next to any invalid control.
For one particular control in my view, I need to set the icon in a slightly different ...
0
votes
1
answer
47
views
Validations string of Page number input
I have a table called dttemp inside c# code, and a column of page number that I get from input. I want to validate function that tells me if there is duplicate string of number in the column. But ...
1
vote
1
answer
905
views
Using INotifyDataErrorInfo on reusable control
I'd like to implement MVVM Toolkit's validation method using reusable controls. My problem is that the warning highlight appears on the whole control, like this:
If I don't use reusable controls, it ...
0
votes
1
answer
59
views
In my WPF control, can I hide the validation control based on the size of the adorned element's row?
I have a user control with many sub controls within a grid. Since there are many controls per row, I'm controlling the visibility of the controls by setting the row height of their containing row to 0 ...
0
votes
0
answers
106
views
DataTable bound to WPF DataGrid Validation in MVVM
I am working on app and part of it is:
load data from SQL database to DataTable (in ViewModel);
provide DataTable data to user (in View) using binding to DataGrid ItemsSource;
user can edit/add/...
0
votes
1
answer
458
views
WPF TextBox: prevent validation rule to fire until user edition
In order to control user input on a WPF TextBox I have bound a validation rule to it. Validation rule works perfectly. It validates if TextBox is empty among other things.
But there is a thing I don't ...
1
vote
1
answer
109
views
How to change a parent by validating a child?
I have a DockPanel that is composed of a button and a textbox. These controls are enclosed by a border. Now I would like to validate the textbox and change the color of the border if the validation ...
0
votes
1
answer
105
views
Update data binding with faulted input vaildation
I have the following WPF Textbox with input validation.
Now the "problem" is, that the validation is not just optical, but a wrong value does not get written into the binded string. But, i ...
1
vote
0
answers
41
views
Unblock row editing on WPF DataGrid
I have validation in DataGrid. I am copying and trying to paste multiple rows. But if there is a validation error in one of the rows on insertion, the validation will will be called in and disable ...
0
votes
1
answer
205
views
Does binding engine also call INotifyDataErrorInfo GetErrors() when ErrorsChanged event is not invoked by viewmodel?
I've got a viewmodel that implements the INotifyDataErrorInfo interface.
When a property is updated and a validation error occurs, I call the ErrorsChanged event, the binding engine then knows it has ...
0
votes
1
answer
177
views
How to read current edited value during Row Validation Rule WPF datagrid
I have this Validation Rule:
public override ValidationResult Validate(object value, CultureInfo cultureInfo) {
DteqModel Dteq = (value as BindingGroup).Items[0] as DteqModel;
if (...
-1
votes
1
answer
362
views
Expose binding validation result in view model
I've followed Microsoft's short tutorial on implementing binding validation in WPF and it's working nicely.
However, I need to expose the result of the validation on the view model, so that my ...
0
votes
1
answer
733
views
WPF xaml: How to validate Cells in DataGrid with automatically generated Columns
How can I add cell validation in an automatically generated DataGrid (from DataTable) and style the cell red if the value is not valid?
This is my DataGrid:
<DataGrid Grid.Row="2"
...
0
votes
1
answer
111
views
How to get user input error from a control in WPF
My issue is that I want to show a user input error. I know about INotifyDataErrorInfo and have it implemented fine, however one outstanding issue is that when I put an invalid value in a DataGrid e.g. ...
0
votes
0
answers
155
views
WPF: combining TextBox input and validation rules
I am learning about properly implementing input validation. I have reviewed dozens of similar questions about different aspects of it, but for my case, combining all these different solutions is ...
0
votes
1
answer
542
views
how to set simple validation on material design textbox in wpf?
i have used all these methods INotifyDataError , validatioOnException , validation Rules and its all working ..
<TextBox x:Name="MobileTextBox" Style="{StaticResource ...
0
votes
1
answer
85
views
WPF Validating a sub-class property with IDataErrorInfo
Given the next example:
Model
public class ProjecteModel : ObservableObject, IProjecteModel
{
private string _patientID
public string IdPacient
{
get => _idPacient;
set
...
1
vote
1
answer
498
views
Binding ValidationRule from ViewModel
I need to use the list 'lFx' from my ModelView
<TextBox Grid.Row="2" Grid.Column="0"
Style="{StaticResource StyleTxtErr}"
Validation.ErrorTemplate=&...
-1
votes
1
answer
496
views
INotifyDataErrorInfo (sometimes) does not work
i wrote a control, derived from Textbox, where I can enter numbers in a special format.
To ensure, this format is correct I also implemented INotifyDataErrorInfo for validation.
However, after a few ...
0
votes
0
answers
48
views
Set ValidationError from code most simple way
In this typical situation we have some dialogs that takes a user through a configure wizard. In one of those dialog steps we have a ComboBox with advanced objects. When SelectionChanged event raises ...
0
votes
2
answers
520
views
How to validate DataGrid selected Item in WPF?
Project: https://github.com/98gzi/Validate-DataGrid-Selected-Item
Goal
My goal is to click on a datagrid row, get the selected item values and bind it to a textbox. So I can edit the values there, ...
0
votes
1
answer
305
views
How to allow minus sign (-) only as the first symbol?
I've created a WPF with a TextBox inside it. I allow the user to enter only numbers, backspace, and minus sign. I would like to allow the user to write minus sign only in the first position, before ...