I am not experianced wiht xaml and i tried mutch things to solve this
simply what i wanted is to implement IDataErrorInfo on textbox
im using this code:
public partial class ExampleWindow: MetroWindow , IDataErrorInfo
{
public ExampleWindow()
{
InitializeComponent();
}
public string this[string columnName] { get { return "Empty Number"; } } //always to be an error
public string Error { get { return string.Empty; } }
}
<Grid>
<TextBox Height="20" Width="200" Controls:TextBoxHelper.Watermark="Enter Text"
Text="{Binding MyText, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True}" />
</Grid>
and what i assume is that my Binding Name isnt good (MyText)
I know this question was here alot times before so im feeling sorry that i couldnt find answer by myself and bother you guys here :(
Someting similar
<Controls:MetroWindow x:Name="Window" .....>
<Grid>
<TextBox Height="20" Width="200" Controls:TextBoxHelper.Watermark="Enter Text"
Text="{Binding ElementName=Window, Path=MyText, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True}" />
</Grid>
</Controls:MetroWindow>
``` c#
public partial class ExampleWindow: MetroWindow , IDataErrorInfo, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
public ExampleWindow()
{
InitializeComponent();
}
private string _MyText;
public string MyText
{
get { return _MyText; }
set
{
_MyText= value;
OnPropertyChanged("MyText");
}
}
public string this [string columnName]
{
get
{
string result = string.Empty;
if (columnName == "MyText")
{
if (string.IsNullOrWhitespace(MyText))
result = "MyText can not be empty";
}
return result;
}
}
public string Error { get { return string.Empty; } }
}
```
Still not working

not shure why :(
show code


i don't see declared name x:Name="Window" in MetroWindow
Wow Thanks :D did not thaught that can be the problem...

Thanks again :D
Issue can be closed now its solved :D