question

BitSmithy-4663 avatar image
0 Votes"
BitSmithy-4663 asked RoyLi-MSFT commented

Problem with improved DataGrid

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?

windows-uwp
· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I tested your code. The issue should be related to the custom DataGrid that you are using. If using a normal DataGrid, everything works correctly. Is there any specific reason that why you want to use a custom DataGrid control?

0 Votes 0 ·

Yes, It is. I am building UserControl. Next I will use it in some apps. I must pass generic parameter to DataGrid and next do a lot of work with it.

0 Votes 0 ·

What is the specific feature that you want to implement for the DataGrid? Maybe you could consider doing it out of the DataGrid, for example in a ViewModel.

0 Votes 0 ·
Show more comments

1 Answer

vb2ae avatar image
0 Votes"
vb2ae answered BitSmithy-4663 commented

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.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I tried Grid.Children.Add() and i also got error. But I will try StackPanel.

0 Votes 0 ·

I tried StacKPanel, it raises error too.

0 Votes 0 ·