Skip to content

Commit

Permalink
#91: Sorting tags alphabetically by default
Browse files Browse the repository at this point in the history
  • Loading branch information
bombomby committed Aug 11, 2019
1 parent 31c07f7 commit ba2c7db
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
22 changes: 22 additions & 0 deletions gui/Controls/Converters.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows;
Expand Down Expand Up @@ -239,4 +241,24 @@ public override ValidationResult Validate(object value, CultureInfo cultureInfo)
return validationResult;
}
}


public class TagListConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is List<Data.Tag>)
{
List<Data.Tag> tags = value as List<Data.Tag>;
return tags.OrderBy(tag => tag.Name);
}
return null;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}

}
8 changes: 6 additions & 2 deletions gui/Controls/TagsControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Data="clr-namespace:Profiler.Data"
xmlns:Data="clr-namespace:Profiler.Data"
xmlns:Profiler="clr-namespace:Profiler"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Profiler:TagListConverter x:Key="TagListConverter" />
</UserControl.Resources>
<Grid>
<ItemsControl ItemsSource="{Binding Mode=OneTime}" Margin="0" >
<ItemsControl ItemsSource="{Binding Mode=OneTime, Converter={StaticResource TagListConverter}}" Margin="0" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
Expand Down

0 comments on commit ba2c7db

Please sign in to comment.