question

MikeWhalley-4456 avatar image
0 Votes"
MikeWhalley-4456 asked ·

WPF DataGrid.ItemsSource in DataGrid inside another DataGrid's RowDetails XAML causing Visual Studio 2019 to crash and exit

That might sound a bit complicated, but I have a datagrid inside the rowdetails of another datagrid in a WPF window. I recently installed version 16.5.3 of VS2019. The WPF window builds and executes successfully, but if I try to edit the .xaml file, the VS2019 Designer fails to load the file and VS2019 closes down without any error message. The same thing does not happen using VS2017, and I have been using, and editing, this XAML code previously for some time.

I have managed to isolate the problem to the following assignment of the rowdetails' datagrid's ItemsSource - this is what is causing VS2019 to crash:

 <DataGrid.ItemsSource>
     <MultiBinding Converter="{StaticResource ValueConverterGetLast30Days}">
          <Binding Path="Transactions"/>
          <Binding  Path="BankAccountID"/>
      </MultiBinding>
 </DataGrid.ItemsSource>  

As you can see, it calls a ValueConverter which creates a list of the items to be inserted into the rowdetails datagrid.

I have managed to work around the problem by creating the datagrid's ItemsSource in code and then adding the data to the datagrid on the LoadingRowDetails event being triggered.

But I am mystified as to why trying to load a WPF window containing this XAML code snippet into the VS2019 Designer (I get the same crash with Blend, incidentally) should cause VS2019 to crash, but not in VS2017 and also while still allowing the Solution to build and execute as expected, and thought I should publicise the problem.


windows-wpf
· 2
10 |1000 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 think you should provide more code about ValueConverterGetLast30Days.I don't know how you MultiBind.

0 Votes 0 ·

@AlexLi-MSFT I am not sure this is relevant in view of the response from @BrandonS-8949 below, but extract from my multi-binding ValuerConverter is:

 public object Convert(object[] values, Type targetType, object parameter,
           System.Globalization.CultureInfo culture)
         {
             int BankAccountID = (int)values[1];
             DateTime back30=DateTime.Today.AddDays(-30);
             var last30Days=
                 from l30 in pmmData.Transactions
                 where l30.Date>= back30
                     && l30.Posted==true
                     && l30.BankAccountID==BankAccountID
                 orderby l30.Date descending
                 select l30;
             return last30Days.ToList();
         }
 etc...
0 Votes 0 ·
BrandonS-8949 avatar image
0 Votes"
BrandonS-8949 answered ·

The crash is due to an error in the last few updates for VS2019. VS2019 will crash when opening up the designer where <Binding/> has been implemented.

Microsoft is aware of the issue and has stated at they are working on it but it is taking a tad longer than I would have anticipated. Especially per the fact that you cannot code in XAML at all while the issue still exists in VS2019.

·
10 |1000 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.

MikeWhalley-4456 avatar image
1 Vote"
MikeWhalley-4456 answered ·

Thank you, but this is very frustrating. There doesn't appear to be any way in VS to open just the XAML code without the designer window as well, other than just using a text editor, which is not ideal.
Can I be informed when there is some progress made by Microsoft in correcting this bug?
Many thanks.

·
10 |1000 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.