Refactored ItemFilterBlockView to use new usercontrol instead of datatemplate spam

This commit is contained in:
Ben
2015-07-04 21:12:47 +01:00
parent d586492de8
commit da3759cd76
7 changed files with 207 additions and 119 deletions

View File

@@ -0,0 +1,83 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using Filtration.Annotations;
using Filtration.ObjectModel;
using Filtration.ObjectModel.BlockItemBaseTypes;
using GalaSoft.MvvmLight.CommandWpf;
namespace Filtration.UserControls
{
public partial class BlockItemControl : INotifyPropertyChanged
{
public BlockItemControl()
{
InitializeComponent();
// ReSharper disable once PossibleNullReferenceException
(Content as FrameworkElement).DataContext = this;
}
public static readonly DependencyProperty BlockItemProperty = DependencyProperty.Register(
"BlockItem",
typeof(IItemFilterBlockItem),
typeof(BlockItemControl),
new FrameworkPropertyMetadata());
public static readonly DependencyProperty RemoveItemCommandProperty = DependencyProperty.Register(
"RemoveItemCommand",
typeof(RelayCommand<IItemFilterBlockItem>),
typeof(BlockItemControl),
new FrameworkPropertyMetadata());
public static readonly DependencyProperty RemoveEnabledProperty = DependencyProperty.Register(
"RemoveEnabled",
typeof(Visibility),
typeof(BlockItemControl),
new FrameworkPropertyMetadata());
public IItemFilterBlockItem BlockItem
{
get
{
return (IItemFilterBlockItem)GetValue(BlockItemProperty);
}
set
{
SetValue(BlockItemProperty, value);
OnPropertyChanged();
}
}
public RelayCommand<IItemFilterBlockItem> RemoveItemCommand
{
get
{
return (RelayCommand<IItemFilterBlockItem>)GetValue(RemoveItemCommandProperty);
}
set
{
SetValue(RemoveItemCommandProperty, value);
}
}
public Visibility RemoveEnabled
{
get
{
return (Visibility)GetValue(RemoveEnabledProperty);
}
set
{
SetValue(RemoveEnabledProperty, value);
}
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}