Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValidationError popup shows only first char of the error string #1926

Closed
QuantumDeveloper opened this issue May 19, 2015 · 3 comments
Closed
Assignees
Milestone

Comments

@QuantumDeveloper
Copy link
Contributor

I am using INotifyDataErrorInfo interface with MA ValidationErrorTemplate like this:

<Style x:Key="ComboBoxStyle" TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
         <Setter Property="VerticalAlignment" Value="Center"/>
         <Setter Property="VerticalContentAlignment" Value="Center"></Setter>
         <Setter Property="HorizontalAlignment" Value="Center"></Setter>
         <Setter Property="MinWidth" Value="50"></Setter>
         <Setter Property="Width" Value="150"></Setter>
         <Setter Property="Validation.ErrorTemplate"
                Value="{StaticResource ValidationErrorTemplate}" />
      </Style>

And use it like this:

<ComboBox Grid.Column="1" Grid.Row="4" Style="{DynamicResource ComboBoxStyle}" ItemsSource="{Binding Source={StaticResource FeatureLevelEnum}}" 
                   SelectedValue="{Binding Path=GraphicsSettingsViewModel.SelectedFeatureLevel, Mode=TwoWay, 
            UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True, NotifyOnValidationError=True}"/>

And validating property:

private void ValidateFeatureLevel(FeatureLevel featureLevel)
      {
         const string propertyKey = "SelectedFeatureLevel";
         if (SelectedAdapterInfo.Adapter != null)
         {
            var isSupported = Device.IsSupportedFeatureLevel(SelectedAdapterInfo.Adapter, featureLevel);

            if (isSupported == false)
            {
               /* Update the collection in the dictionary returned by the GetErrors method */
               if (!validationErrors.ContainsKey(propertyKey))
               {
                  validationErrors.Add(propertyKey, "This feature level is not supported on current video adapter");
               }
            }
            else if (validationErrors.ContainsKey(propertyKey))
            {
               /* Remove all errors for this property */
               validationErrors.Remove(propertyKey);
            }
            RaisePropertyChangedByName("HasErrors");
            RaiseErrorsChanged(propertyKey);
         }
      }

But as A result I see only first char of validation string:
image

Could you please help me and say why this happening?

@punker76
Copy link
Member

@QuantumDeveloper what is validationErrors? can you privide more code?

@QuantumDeveloper
Copy link
Contributor Author

@punker76

private readonly Dictionary<string, string>
        validationErrors = new Dictionary<string, string>();

and How I call the validation method:

public FeatureLevel SelectedFeatureLevel
      {
         get { return selectedFeatureLevel; }
         set
         {
            selectedFeatureLevel = value;
            RaisePropertyChanged();
            ValidateFeatureLevel(value);
            if (selectedFeatureLevel != currentFeatureLevel)
            {
               ParametersChanged = true;
            }
            else
            {
               ParametersChanged = false;
            }
         }
      }

@punker76 punker76 self-assigned this May 22, 2015
@punker76 punker76 added this to the 1.2.0 milestone Jul 28, 2015
@punker76
Copy link
Member

fixed and enabled with ba6cf29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants