How to make validation for a virtualized list?

I have a listView with userControl in ItemTemplate. This UserControl contains some text fields that I need to check. Everything worked fine until I turned on virtualization for ListView. Now the check is performed only for visible elements.

How can i solve this?

+3
source share
1 answer

Since user interface virtualization processes visual containers, it will reset them, so the solution will be to manually bind to some properties in the user control and perform your check in the view model. Then, when it fails the test, change the color and size of the UserControl frame to a red and thicker border.

<UserControl...>
  <Grid>
    <Border BorderThickness="{Binding Path=Border_Thickness_property}" BorderBrush="{Binding Path=Border_brush_color}">

    <!-- Put your textboxes and such here... -->

    </Border>
  </Grid>
</UserControl>

link: http://www.codeproject.com/Articles/34405/WPF-Data-Virtualization

OR

You could use the View Model to implement IDataErrorInfo and use this interface to define your validation rules.

This site has a nice example.

+1
source

All Articles