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.86k stars 1.37k forks source link

DataGridComboBoxColumn bindings produce an exception if you use a converter. #4513

Open Siyh opened 2 years ago

Siyh commented 2 years ago

Describe the bug

See here for details.

Regression

No response

Reproducible in sample app?

Steps to reproduce

Running the code on the stackoverflow example linked above produces an exception.

Expected behavior

Comboboxes with displayed values that differ from those underlying.

Screenshots

No response

Windows Build Number

Other Windows Build number

No response

App minimum and target SDK version

Other SDK version

No response

Visual Studio Version

2022

Visual Studio Build Number

No response

Device form factor

Desktop

Nuget packages

No response

Additional context

No response

Help us help you

No.

ghost commented 2 years ago

Hello Siyh, 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 πŸ™Œ

ghost commented 2 years ago

This issue has been marked as "needs attention πŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 2 years ago

This issue has been marked as "needs attention πŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 2 years ago

This issue has been marked as "needs attention πŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 2 years ago

This issue has been marked as "needs attention πŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 2 years ago

This issue has been marked as "needs attention πŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 2 years ago

This issue has been marked as "needs attention πŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 2 years ago

This issue has been marked as "needs attention πŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

ghost commented 2 years ago

This issue has been marked as "needs attention πŸ‘‹" due to no activity for 15 days. Please triage the issue so the fix can be established.

mahfuzmr commented 2 years ago

In my case, I just use Converter as suggested in WPF, and that caused Parsing Error. Samples are below: xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"

XAML: <controls:DataGridTextColumn Binding="{Binding UploadDate, Converter={StaticResource DateTimeConverter}}" Header="Date" />

And in the code behind:

public class DateTimeConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { if (value is DateTime) { var test = (DateTime)value; if (test == DateTime.MinValue) { return "None"; } var date = test.ToString("dd.MM.yyyy"); return (date); } return string.Empty; } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } }