WindowsCommunityToolkit icon indicating copy to clipboard operation
WindowsCommunityToolkit copied to clipboard

DataGridComboBoxColumn bindings produce an exception if you use a converter.

Open Siyh opened this issue 2 years ago • 10 comments

Describe the bug

See here for details.

Regression

No response

Reproducible in sample app?

  • [ ] This bug can be reproduced in the 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

  • [ ] Windows 10 1809 (Build 17763)
  • [ ] Windows 10 1903 (Build 18362)
  • [ ] Windows 10 1909 (Build 18363)
  • [ ] Windows 10 2004 (Build 19041)
  • [ ] Windows 10 20H2 (Build 19042)
  • [ ] Windows 10 21H1 (Build 19043)
  • [ ] Windows 11 21H2 (Build 22000)
  • [ ] Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • [ ] Windows 10, version 1809 (Build 17763)
  • [ ] Windows 10, version 1903 (Build 18362)
  • [ ] Windows 10, version 1909 (Build 18363)
  • [ ] Windows 10, version 2004 (Build 19041)
  • [ ] Other (specify)

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.

Siyh avatar Mar 17 '22 17:03 Siyh

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 avatar Mar 17 '22 17:03 ghost

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 avatar Apr 01 '22 22:04 ghost

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 avatar Apr 17 '22 01:04 ghost

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 avatar May 02 '22 04:05 ghost

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 avatar May 17 '22 07:05 ghost

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 avatar Jun 01 '22 07:06 ghost

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 avatar Jun 16 '22 07:06 ghost

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 avatar Jul 01 '22 07:07 ghost

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 avatar Jul 16 '22 10:07 ghost

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(); } }

mahfuzmr avatar Jul 22 '22 11:07 mahfuzmr