Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Columns/TableViewDateColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using System;
using Windows.Globalization.DateTimeFormatting;
using Windows.System.UserProfile;
using WinUI.TableView.Controls;
using WinUI.TableView.Extensions;
using WinUI.TableView.Helpers;
Expand All @@ -19,6 +21,16 @@
#endif
public partial class TableViewDateColumn : TableViewBoundColumn
{
/// <summary>
/// Initializes a new instance of the TableViewDateColumn class.
/// </summary>
public TableViewDateColumn()
{
var languages = GlobalizationPreferences.Languages;
var patterns = languages.Count > 0 ? new DateTimeFormatter("shortdate", languages).Patterns : null;
DateFormat = patterns?.Count > 0 ? patterns[0] : "shortdate";
}

/// <summary>
/// Generates a TextBlock element for the cell.
/// </summary>
Expand Down Expand Up @@ -107,7 +119,7 @@

if (!string.IsNullOrEmpty(PropertyPath))
{
var propertyInfo = type.GetProperty(PropertyPath);

Check warning on line 122 in src/Columns/TableViewDateColumn.cs

View workflow job for this annotation

GitHub Actions / build (ARM64)

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Check warning on line 122 in src/Columns/TableViewDateColumn.cs

View workflow job for this annotation

GitHub Actions / build (x64)

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Check warning on line 122 in src/Columns/TableViewDateColumn.cs

View workflow job for this annotation

GitHub Actions / build

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
if (propertyInfo is not null)
{
type = propertyInfo.PropertyType;
Expand Down
5 changes: 3 additions & 2 deletions src/Columns/TableViewTimeColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using System;
using Windows.Globalization.DateTimeFormatting;
using Windows.System.UserProfile;
using WinUI.TableView.Controls;
using WinUI.TableView.Extensions;
using WinUI.TableView.Helpers;
Expand All @@ -24,7 +24,8 @@
/// </summary>
public TableViewTimeColumn()
{
ClockIdentifier = DateTimeFormatter.LongTime.Clock;
var clocks = GlobalizationPreferences.Clocks;
ClockIdentifier = clocks.Count > 0 ? clocks[0] : "24HourClock";
}

/// <summary>
Expand Down Expand Up @@ -110,7 +111,7 @@

if (!string.IsNullOrEmpty(PropertyPath))
{
var propertyInfo = type.GetProperty(PropertyPath);

Check warning on line 114 in src/Columns/TableViewTimeColumn.cs

View workflow job for this annotation

GitHub Actions / build (ARM64)

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Check warning on line 114 in src/Columns/TableViewTimeColumn.cs

View workflow job for this annotation

GitHub Actions / build (x86)

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Check warning on line 114 in src/Columns/TableViewTimeColumn.cs

View workflow job for this annotation

GitHub Actions / build (x64)

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.

Check warning on line 114 in src/Columns/TableViewTimeColumn.cs

View workflow job for this annotation

GitHub Actions / build

'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperty(String)'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
if (propertyInfo is not null)
{
type = propertyInfo.PropertyType;
Expand Down
5 changes: 3 additions & 2 deletions tests/TableViewTimeColumnTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;
using System;
using Windows.Globalization.DateTimeFormatting;
using Windows.System.UserProfile;
using WinUI.TableView.Controls;
using WinUI.TableView.Helpers;

Expand Down Expand Up @@ -33,7 +33,8 @@ public void TableViewTimeColumn_GeneratesEditingElementWithConfiguredProperties(
Assert.AreEqual(TableViewLocalizedStrings.TimePickerPlaceholder, element.PlaceholderText);
Assert.AreEqual(typeof(TimeOnly), element.SourceType);
Assert.AreEqual(item.AppointmentTime, column.PrepareCellForEdit(cell, new RoutedEventArgs()));
Assert.AreEqual(DateTimeFormatter.LongTime.Clock, new TableViewTimeColumn().ClockIdentifier);
var clocks = GlobalizationPreferences.Clocks;
Assert.AreEqual(clocks.Count > 0 ? clocks[0] : "24HourClock", new TableViewTimeColumn().ClockIdentifier);
}

[UITestMethod]
Expand Down
Loading