You could refer to the code below.
Xaml:
<StackPanel>
<DataGrid AutoGenerateColumns="False" Height="200" x:Name="dg" Width="350" ItemsSource="{Binding Users}" SelectionMode="Extended"
SelectedItem="{Binding SelecedItme ,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding Id,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<DataGridTextColumn Header="Name" Binding="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</DataGrid.Columns>
</DataGrid>
<TextBlock x:Name="tb" Text="{Binding ElementName=dg, Path=SelectedItems.Count, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" Width="350" Background="AliceBlue"/>
</StackPanel>
Codebedhind:
----------------------------------------------------------------------------
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.