I recommend defining a style for the DataGridRow that will be tied to visibility, whether it should be displayed or not. Just repeating through the lines will not be enough, as I mentioned in @ RV1987's answer.
<DataGrid> <DataGrid.Resources> <Style TargetType="DataGridRow"> <Setter Property="Visibility" Value="{Binding ...}" /> </Style> </DataGrid.Resources> </DataGrid>
EDIT:
What you link depends on where you store information about whether to display the string. For example, if every data object in your linked collection has a bool ShouldBeDisplayed property, you have something like this:
<DataGrid> <DataGrid.Resources> <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" /> <Style TargetType="DataGridRow"> <Setter Property="Visibility" Value="{Binding Path=ShouldBeDisplayed, Converter={StaticResource booleanToVisibilityConverter}}" /> </Style> </DataGrid.Resources> </DataGrid>
source share