Checking If Any WPF DataGrid Cell Has Error

前端 未结 1 2044
遥遥无期
遥遥无期 2021-01-05 07:33

I have validation set up on the cells and it works as expected (placing a red highlight around the textbox and adding a tooltip with the error). However, If I try to access

1条回答
  •  孤城傲影
    2021-01-05 08:04

    You might run into problems with virtualization with this but you probably do have to look at the containers:

    var errors = (from c in
                      (from object i in _myGrid.ItemsSource
                       select _myGrid.ItemContainerGenerator.ContainerFromItem(i))
                  where c != null
                  select Validation.GetHasError(c))
                 .FirstOrDefault(x => x);
    if (errors)
    {
        //There be errors
    }
    

    0 讨论(0)
提交回复
热议问题