Problem with improved DataGrid

BitSmithy 1,751 Reputation points
2021-10-02T21:46:31.847+00:00

Hello,

I have Page with BORDER

<Page
x:Class="DGT_TEST.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DGT_TEST"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
Loaded="Page_Loaded"
>

<Grid>
    <Border x:Name="brd1"></Border>
</Grid>

</Page>

In Loaded event I try to put to this border a DataGrid wich I improved a bit.

    private void Page_Loaded(object sender, RoutedEventArgs e)
    {
        brd1.Child = new DGT<MyClass>();
    }

public class DGT<T> : DataGrid
{
}

public class MyClass : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
}

But when I try to run this code in release mode, an error occurs.

How to pass this problem?

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. Ken Tucker 5,846 Reputation points
    2021-10-03T10:44:53.09+00:00

    The border is not a container control so you cant add controls to it. I would try putting a StackPanel inside the border and add the DataGrid to the stackpanel.