Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed single-click-edit feature #32

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
39 changes: 23 additions & 16 deletions src/SampleApp/App.xaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Application
x:Class="SampleApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SampleApp">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
</ResourceDictionary>
</Application.Resources>
</Application>
<?xml version="1.0" encoding="utf-8" ?>
<Application
x:Class="SampleApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SampleApp"
RequestedTheme="Dark">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>

<!-- Other app resources here -->
<Color x:Key="GC1">#20192E3D</Color>
<Color x:Key="GC2">#20335F7F</Color>
<Color x:Key="GC3">#204E91C4</Color>
<Color x:Key="GC4">#2066BCFF</Color>

</ResourceDictionary>
</Application.Resources>
</Application>
550 changes: 500 additions & 50 deletions src/SampleApp/App.xaml.cs

Large diffs are not rendered by default.

Binary file added src/SampleApp/Assets/Info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/SampleApp/Assets/StoreLogo.ico
Binary file not shown.
Binary file added src/SampleApp/Assets/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/SampleApp/Assets/StoreLogoAlt.ico
Binary file not shown.
Binary file added src/SampleApp/Assets/StoreLogoAlt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/SampleApp/Assets/Warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 41 additions & 73 deletions src/SampleApp/DataGridDataItem.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -14,27 +10,29 @@ namespace SampleApp;

public class DataGridDataItem : INotifyDataErrorInfo, IComparable, INotifyPropertyChanged
{
private Dictionary<string, List<string>> _errors = new Dictionary<string, List<string>>();
private uint _rank;
private string _mountain;
private uint _height;
private string _range;
private string _parentMountain;
private string coordinates;
private uint prominence;
private DateTimeOffset first_ascent;
private string ascents;
string _mountain;
string _range;
string _parentMountain;
string _coordinates;
string _ascents;
uint _rank;
uint _height;
uint _prominence;
DateTimeOffset _firstAscent;
Dictionary<string, List<string>> _errors = new Dictionary<string, List<string>>();

public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;
public event PropertyChangedEventHandler PropertyChanged;
public event PropertyChangedEventHandler PropertyChanged;

void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
if (!string.IsNullOrEmpty(propertyName))
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

public uint Rank
{
get
{
return _rank;
}

get => _rank;
set
{
if (_rank != value)
Expand All @@ -47,11 +45,7 @@ public uint Rank

public string Mountain
{
get
{
return _mountain;
}

get => _mountain;
set
{
if (_mountain != value)
Expand Down Expand Up @@ -79,11 +73,7 @@ public string Mountain

public uint Height_m
{
get
{
return _height;
}

get => _height;
set
{
if (_height != value)
Expand All @@ -96,11 +86,7 @@ public uint Height_m

public string Range
{
get
{
return _range;
}

get => _range;
set
{
if (_range != value)
Expand Down Expand Up @@ -128,11 +114,7 @@ public string Range

public string Parent_mountain
{
get
{
return _parentMountain;
}

get => _parentMountain;
set
{
if (_parentMountain != value)
Expand Down Expand Up @@ -160,96 +142,82 @@ public string Parent_mountain

public string Coordinates
{
get => coordinates;
get => _coordinates;
set
{
if (coordinates != value)
if (_coordinates != value)
{
coordinates = value;
_coordinates = value;
OnPropertyChanged();
}
}
}

public uint Prominence
{
get => prominence;
get => _prominence;
set
{
if (prominence != value)
if (_prominence != value)
{
prominence = value;
_prominence = value;
OnPropertyChanged();
}
}
}

// You need to use DateTimeOffset to get proper binding to the CalendarDatePicker control, DateTime won't work.
/// <summary>
/// You need to use DateTimeOffset to get proper binding to the CalendarDatePicker control, DateTime won't work.
/// </summary>
public DateTimeOffset First_ascent
{
get => first_ascent; set
get => _firstAscent;
set
{
if (first_ascent != value)
if (_firstAscent != value)
{
first_ascent = value;
_firstAscent = value;
OnPropertyChanged();
}
}
}

public string Ascents
{
get => ascents; set
get => _ascents;
set
{
if (ascents != value)
if (_ascents != value)
{
ascents = value;
_ascents = value;
OnPropertyChanged();
}
}
}

bool INotifyDataErrorInfo.HasErrors
{
get
{
return _errors.Keys.Count > 0;
}
get => _errors.Keys.Count > 0;
}

IEnumerable INotifyDataErrorInfo.GetErrors(string propertyName)
{
if (propertyName == null)
{
propertyName = string.Empty;
}

if (_errors.ContainsKey(propertyName))
{
return _errors[propertyName];
}
else
{
return null;
}
}

int IComparable.CompareTo(object obj)
{
int lnCompare = Range.CompareTo((obj as DataGridDataItem).Range);

if (lnCompare == 0)
{
return Parent_mountain.CompareTo((obj as DataGridDataItem).Parent_mountain);
}
else
{
return lnCompare;
}
}

private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
Loading