Hi,@Arivazhagan K. Welcome Microsoft Q&A. You could try to use the following code.
First, give the DataGrid a name in the subForm.xaml file:
<DataGrid x:Name="myDataGrid" ...>
<!-- DataGrid content -->
</DataGrid>
In the main page, after loading the subForm into the frame, you can access the DataGrid as follows:
nav_Frame.Source = new Uri("UserControls/subForm.xaml", UriKind.RelativeOrAbsolute);
var subForm = nav_Frame.Content as FrameworkElement; // Get the content of the frame
var dataGrid = subForm?.FindName("myDataGrid") as DataGrid; // Find the DataGrid by its name
if (dataGrid != null)
{
// For example, you can retrieve data from the DataGrid
var data = dataGrid.ItemsSource; // Assuming you have set the ItemsSource for the DataGrid
// Do something with the data
}
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.