CommunityToolkit / WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helpers, extensions, and custom controls. It simplifies and demonstrates common developer tasks building .NET apps with UWP and the Windows App SDK / WinUI 3 for Windows 10 and Windows 11. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/communitytoolkit/
Other
5.88k stars 1.38k forks source link

DataGrid not working (WinUI 3 WinAppSDK 1.0 Preview 3) #4366

Open cbuduknui opened 2 years ago

cbuduknui commented 2 years ago
<ctwuc:GridSplitter Grid.Column="1" MinWidth="150" MaxWidth="500" 
                            ResizeDirection="Columns" VerticalAlignment="Stretch" Visibility="{x:Bind DptmentTreeVisible,Mode=OneWay}" />

<ctwuc:DataGrid
            Grid.Row="2"
            BorderThickness="1"
            BorderBrush="LightGray"
            AutoGenerateColumns="False"
            FrozenColumnCount="5"
            HeadersVisibility="All"
            GridLinesVisibility="All"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            ItemsSource="{x:Bind MonthDispatchInfoList,Mode=OneWay}"
            SelectedItem="{x:Bind SelectedMonthDispatch,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">

            <ctwuc:DataGrid.Columns>
                <ctwuc:DataGridCheckBoxColumn Binding="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
                    <ctwuc:DataGridCheckBoxColumn.Header>
                        <CheckBox Checked="MonthDispatchCheckBox_Checked" Unchecked="MonthDispatchCheckBox_Checked" HorizontalAlignment="Center"/>
                    </ctwuc:DataGridCheckBoxColumn.Header>
                </ctwuc:DataGridCheckBoxColumn>

            </ctwuc:DataGrid.Columns>
        </ctwuc:DataGrid>

Describe the bug

Debug run program throw exception: 0x77CFEAE2 处(位于 ExpertDispatchDAdmin3.exe 中)引发的异常: Microsoft C++ 异常: winrt::hresult_error,位于内存位置 0x0303BA48 处

Environment

Windows 11 22000.282

Package Version(s): WinAppSDK 1.0 Preview 3 CommunityToolkit.WinUI.UI.Controls 7.1.1-preview3

Windows 11 Build Number:

App min and target version:

Device form factor:

Visual Studio version:

ghost commented 2 years ago

Hello cbuduknui, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

michael-hawker commented 2 years ago

@azchohfi I know you said DataGrid seemed to work for you in our sample app, but have been getting some other reports about Win 11, were you testing on Win10 or 11 at the time? I know the UWP one works on Win 11 fine.

@cbuduknui do you have an isolated sample you could share?

cbuduknui commented 2 years ago

I have no windows 10 environment right now. At win11,I create a sample:

<Window x:Class="App2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App2" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ctwuc="using:CommunityToolkit.WinUI.UI.Controls" mc:Ignorable="d">

<Grid>
    <ctwuc:DataGrid>
        <ctwuc:DataGrid.Columns>
            <ctwuc:DataGridCheckBoxColumn>
                <ctwuc:DataGridCheckBoxColumn.Header>
                    <CheckBox Checked="MonthDispatchCheckBox_Checked" Unchecked="MonthDispatchCheckBox_Checked" HorizontalAlignment="Center"/>
                </ctwuc:DataGridCheckBoxColumn.Header>
            </ctwuc:DataGridCheckBoxColumn>
        </ctwuc:DataGrid.Columns>
    </ctwuc:DataGrid>
</Grid>

namespace App2 { ///

/// An empty window that can be used on its own or navigated to within a Frame. /// public sealed partial class MainWindow : Window { public MainWindow() { this.InitializeComponent(); }

    private void MonthDispatchCheckBox_Checked(object sender, RoutedEventArgs e)
    {

    }
}

}

Run debug x86 throw exception: 0x09C3B966 (Microsoft.ui.xaml.dll) (App2.exe 中)处有未经处理的异常: 0xC000027B: 发生应用程序内部异常。 (参数: 0x099F8E08, 0x00000002)。

Run debug x64 throw exception: 0x0931B966 (Microsoft.ui.xaml.dll) (App2.exe 中)处有未经处理的异常: 0xC000027B: 发生应用程序内部异常。 (参数: 0x05390408, 0x00000003)。