51 changed files with 1675 additions and 194 deletions
@ -1,41 +0,0 @@ |
|||
using System; |
|||
using System.Globalization; |
|||
using System.Reflection; |
|||
using System.Windows.Input; |
|||
using Avalonia.Utilities; |
|||
|
|||
namespace Avalonia.Data.Converters |
|||
{ |
|||
class AlwaysEnabledDelegateCommand : ICommand |
|||
{ |
|||
private readonly Delegate action; |
|||
|
|||
private ParameterInfo parameterInfo; |
|||
|
|||
public AlwaysEnabledDelegateCommand(Delegate action) |
|||
{ |
|||
this.action = action; |
|||
var parameters = action.Method.GetParameters(); |
|||
parameterInfo = parameters.Length == 0 ? null : parameters[0]; |
|||
} |
|||
|
|||
#pragma warning disable 0067
|
|||
public event EventHandler CanExecuteChanged; |
|||
#pragma warning restore 0067
|
|||
|
|||
public bool CanExecute(object parameter) => true; |
|||
|
|||
public void Execute(object parameter) |
|||
{ |
|||
if (parameterInfo == null) |
|||
{ |
|||
action.DynamicInvoke(); |
|||
} |
|||
else |
|||
{ |
|||
TypeUtilities.TryConvert(parameterInfo.ParameterType, parameter, CultureInfo.CurrentCulture, out object convertedParameter); |
|||
action.DynamicInvoke(convertedParameter); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,230 @@ |
|||
using System; |
|||
using System.ComponentModel; |
|||
using System.Globalization; |
|||
using System.Linq; |
|||
using System.Linq.Expressions; |
|||
using System.Reflection; |
|||
using System.Windows.Input; |
|||
using Avalonia.Utilities; |
|||
|
|||
namespace Avalonia.Data.Converters |
|||
{ |
|||
class MethodToCommandConverter : ICommand |
|||
{ |
|||
readonly static Func<object, bool> AlwaysEnabled = (_) => true; |
|||
readonly static MethodInfo tryConvert = typeof(TypeUtilities) |
|||
.GetMethod(nameof(TypeUtilities.TryConvert), BindingFlags.Public | BindingFlags.Static); |
|||
readonly static PropertyInfo currentCulture = typeof(CultureInfo) |
|||
.GetProperty(nameof(CultureInfo.CurrentCulture), BindingFlags.Public | BindingFlags.Static); |
|||
readonly Func<object, bool> canExecute; |
|||
readonly Action<object> execute; |
|||
readonly WeakPropertyChangedProxy weakPropertyChanged; |
|||
readonly PropertyChangedEventHandler propertyChangedEventHandler; |
|||
readonly string[] dependencyProperties; |
|||
|
|||
public MethodToCommandConverter(Delegate action) |
|||
{ |
|||
var target = action.Target; |
|||
var canExecuteMethodName = "Can" + action.Method.Name; |
|||
var parameters = action.Method.GetParameters(); |
|||
var parameterInfo = parameters.Length == 0 ? null : parameters[0].ParameterType; |
|||
|
|||
if (parameterInfo == null) |
|||
{ |
|||
execute = CreateExecute(target, action.Method); |
|||
} |
|||
else |
|||
{ |
|||
execute = CreateExecute(target, action.Method, parameterInfo); |
|||
} |
|||
|
|||
var canExecuteMethod = action.Method.DeclaringType.GetRuntimeMethods() |
|||
.FirstOrDefault(m => m.Name == canExecuteMethodName |
|||
&& m.GetParameters().Length == 1 |
|||
&& m.GetParameters()[0].ParameterType == typeof(object)); |
|||
if (canExecuteMethod == null) |
|||
{ |
|||
canExecute = AlwaysEnabled; |
|||
} |
|||
else |
|||
{ |
|||
canExecute = CreateCanExecute(target, canExecuteMethod); |
|||
dependencyProperties = canExecuteMethod |
|||
.GetCustomAttributes(typeof(Metadata.DependsOnAttribute), true) |
|||
.OfType<Metadata.DependsOnAttribute>() |
|||
.Select(x => x.Name) |
|||
.ToArray(); |
|||
if (dependencyProperties.Any() |
|||
&& target is INotifyPropertyChanged inpc) |
|||
{ |
|||
propertyChangedEventHandler = OnPropertyChanged; |
|||
weakPropertyChanged = new WeakPropertyChangedProxy(inpc, propertyChangedEventHandler); |
|||
} |
|||
} |
|||
} |
|||
|
|||
void OnPropertyChanged(object sender,PropertyChangedEventArgs args) |
|||
{ |
|||
if (string.IsNullOrWhiteSpace(args.PropertyName) |
|||
|| dependencyProperties?.Contains(args.PropertyName) == true) |
|||
{ |
|||
Threading.Dispatcher.UIThread.Post(() => CanExecuteChanged?.Invoke(this, EventArgs.Empty) |
|||
, Threading.DispatcherPriority.Input); |
|||
} |
|||
} |
|||
|
|||
#pragma warning disable 0067
|
|||
public event EventHandler CanExecuteChanged; |
|||
#pragma warning restore 0067
|
|||
|
|||
public bool CanExecute(object parameter) => canExecute(parameter); |
|||
|
|||
public void Execute(object parameter) => execute(parameter); |
|||
|
|||
|
|||
static Action<object> CreateExecute(object target |
|||
, System.Reflection.MethodInfo method) |
|||
{ |
|||
|
|||
var parameter = Expression.Parameter(typeof(object), "parameter"); |
|||
|
|||
var instance = Expression.Convert |
|||
( |
|||
Expression.Constant(target), |
|||
method.DeclaringType |
|||
); |
|||
|
|||
|
|||
var call = Expression.Call |
|||
( |
|||
instance, |
|||
method |
|||
); |
|||
|
|||
|
|||
return Expression |
|||
.Lambda<Action<object>>(call, parameter) |
|||
.Compile(); |
|||
} |
|||
|
|||
static Action<object> CreateExecute(object target |
|||
, System.Reflection.MethodInfo method |
|||
, Type parameterType) |
|||
{ |
|||
|
|||
var parameter = Expression.Parameter(typeof(object), "parameter"); |
|||
|
|||
var instance = Expression.Convert |
|||
( |
|||
Expression.Constant(target), |
|||
method.DeclaringType |
|||
); |
|||
|
|||
Expression body; |
|||
|
|||
if (parameterType == typeof(object)) |
|||
{ |
|||
body = Expression.Call(instance, |
|||
method, |
|||
parameter |
|||
); |
|||
} |
|||
else |
|||
{ |
|||
var arg0 = Expression.Variable(typeof(object), "argX"); |
|||
var convertCall = Expression.Call(tryConvert, |
|||
Expression.Constant(parameterType), |
|||
parameter, |
|||
Expression.Property(null, currentCulture), |
|||
arg0 |
|||
); |
|||
|
|||
var call = Expression.Call(instance, |
|||
method, |
|||
Expression.Convert(arg0, parameterType) |
|||
); |
|||
body = Expression.Block(new[] { arg0 }, |
|||
convertCall, |
|||
call |
|||
); |
|||
|
|||
} |
|||
Action<object> action = null; |
|||
try |
|||
{ |
|||
action = Expression |
|||
.Lambda<Action<object>>(body, parameter) |
|||
.Compile(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
throw ex; |
|||
} |
|||
return action; |
|||
} |
|||
|
|||
static Func<object, bool> CreateCanExecute(object target |
|||
, System.Reflection.MethodInfo method) |
|||
{ |
|||
var parameter = Expression.Parameter(typeof(object), "parameter"); |
|||
var instance = Expression.Convert |
|||
( |
|||
Expression.Constant(target), |
|||
method.DeclaringType |
|||
); |
|||
var call = Expression.Call |
|||
( |
|||
instance, |
|||
method, |
|||
parameter |
|||
); |
|||
return Expression |
|||
.Lambda<Func<object, bool>>(call, parameter) |
|||
.Compile(); |
|||
} |
|||
|
|||
|
|||
internal class WeakPropertyChangedProxy |
|||
{ |
|||
readonly WeakReference<PropertyChangedEventHandler> _listener = new WeakReference<PropertyChangedEventHandler>(null); |
|||
readonly PropertyChangedEventHandler _handler; |
|||
internal WeakReference<INotifyPropertyChanged> Source { get; } = new WeakReference<INotifyPropertyChanged>(null); |
|||
|
|||
public WeakPropertyChangedProxy() |
|||
{ |
|||
_handler = new PropertyChangedEventHandler(OnPropertyChanged); |
|||
} |
|||
|
|||
public WeakPropertyChangedProxy(INotifyPropertyChanged source, PropertyChangedEventHandler listener) : this() |
|||
{ |
|||
SubscribeTo(source, listener); |
|||
} |
|||
|
|||
public void SubscribeTo(INotifyPropertyChanged source, PropertyChangedEventHandler listener) |
|||
{ |
|||
source.PropertyChanged += _handler; |
|||
|
|||
Source.SetTarget(source); |
|||
_listener.SetTarget(listener); |
|||
} |
|||
|
|||
public void Unsubscribe() |
|||
{ |
|||
if (Source.TryGetTarget(out INotifyPropertyChanged source) && source != null) |
|||
source.PropertyChanged -= _handler; |
|||
|
|||
Source.SetTarget(null); |
|||
_listener.SetTarget(null); |
|||
} |
|||
|
|||
void OnPropertyChanged(object sender, PropertyChangedEventArgs e) |
|||
{ |
|||
if (_listener.TryGetTarget(out var handler) && handler != null) |
|||
handler(sender, e); |
|||
else |
|||
Unsubscribe(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,645 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Styles.Resources> |
|||
<Thickness x:Key="DataGridTextColumnCellTextBlockMargin">12,0,12,0</Thickness> |
|||
|
|||
<x:Double x:Key="ListAccentLowOpacity">0.6</x:Double> |
|||
<x:Double x:Key="ListAccentMediumOpacity">0.8</x:Double> |
|||
|
|||
<StreamGeometry x:Key="DataGridSortIconAscendingPath">M1875 1011l-787 787v-1798h-128v1798l-787 -787l-90 90l941 941l941 -941z</StreamGeometry> |
|||
<StreamGeometry x:Key="DataGridSortIconDescendingPath">M1965 947l-941 -941l-941 941l90 90l787 -787v1798h128v-1798l787 787z</StreamGeometry> |
|||
<StreamGeometry x:Key="DataGridRowGroupHeaderIconClosedPath">M515 93l930 931l-930 931l90 90l1022 -1021l-1022 -1021z</StreamGeometry> |
|||
<StreamGeometry x:Key="DataGridRowGroupHeaderIconOpenedPath">M1939 1581l90 -90l-1005 -1005l-1005 1005l90 90l915 -915z</StreamGeometry> |
|||
|
|||
<SolidColorBrush x:Key="DataGridGridLinesBrush" |
|||
Color="{StaticResource SystemBaseMediumLowColor}" |
|||
Opacity="0.4" /> |
|||
<SolidColorBrush x:Key="DataGridDropLocationIndicatorBackground" |
|||
Color="#3F4346" /> |
|||
<SolidColorBrush x:Key="DataGridDisabledVisualElementBackground" |
|||
Color="#8CFFFFFF" /> |
|||
<SolidColorBrush x:Key="DataGridFillerGridLinesBrush" |
|||
Color="Transparent" /> |
|||
<SolidColorBrush x:Key="DataGridCurrencyVisualPrimaryBrush" |
|||
Color="Transparent" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderBackgroundColor" |
|||
ResourceKey="SystemAltHighColor" /> |
|||
<SolidColorBrush x:Key="DataGridColumnHeaderBackgroundBrush" |
|||
Color="{StaticResource DataGridColumnHeaderBackgroundColor}" /> |
|||
<StaticResource x:Key="DataGridScrollBarsSeparatorBackground" |
|||
ResourceKey="SystemChromeLowColor" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderForegroundBrush" |
|||
ResourceKey="SystemControlForegroundBaseMediumBrush" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderHoveredBackgroundColor" |
|||
ResourceKey="SystemListLowColor" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderPressedBackgroundColor" |
|||
ResourceKey="SystemListMediumColor" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderDraggedBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundChromeMediumLowBrush" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderPointerOverBrush" |
|||
ResourceKey="SystemControlHighlightListLowBrush" /> |
|||
<StaticResource x:Key="DataGridColumnHeaderPressedBrush" |
|||
ResourceKey="SystemControlHighlightListMediumBrush" /> |
|||
<StaticResource x:Key="DataGridDetailsPresenterBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundChromeMediumLowBrush" /> |
|||
<StaticResource x:Key="DataGridFillerColumnGridLinesBrush" |
|||
ResourceKey="DataGridFillerGridLinesBrush" /> |
|||
<StaticResource x:Key="DataGridRowSelectedBackgroundColor" |
|||
ResourceKey="SystemAccentColor" /> |
|||
<StaticResource x:Key="DataGridRowSelectedBackgroundOpacity" |
|||
ResourceKey="ListAccentLowOpacity" /> |
|||
<StaticResource x:Key="DataGridRowSelectedHoveredBackgroundColor" |
|||
ResourceKey="SystemAccentColor" /> |
|||
<StaticResource x:Key="DataGridRowSelectedHoveredBackgroundOpacity" |
|||
ResourceKey="ListAccentMediumOpacity" /> |
|||
<StaticResource x:Key="DataGridRowSelectedUnfocusedBackgroundColor" |
|||
ResourceKey="SystemAccentColor" /> |
|||
<StaticResource x:Key="DataGridRowSelectedUnfocusedBackgroundOpacity" |
|||
ResourceKey="ListAccentLowOpacity" /> |
|||
<StaticResource x:Key="DataGridRowSelectedHoveredUnfocusedBackgroundColor" |
|||
ResourceKey="SystemAccentColor" /> |
|||
<StaticResource x:Key="DataGridRowSelectedHoveredUnfocusedBackgroundOpacity" |
|||
ResourceKey="ListAccentMediumOpacity" /> |
|||
<StaticResource x:Key="DataGridRowHeaderForegroundBrush" |
|||
ResourceKey="SystemControlForegroundBaseMediumBrush" /> |
|||
<StaticResource x:Key="DataGridRowHeaderBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundAltHighBrush" /> |
|||
<StaticResource x:Key="DataGridRowGroupHeaderBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundChromeMediumBrush" /> |
|||
<StaticResource x:Key="DataGridRowGroupHeaderHoveredBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundListLowBrush" /> |
|||
<StaticResource x:Key="DataGridRowGroupHeaderPressedBackgroundBrush" |
|||
ResourceKey="SystemControlBackgroundListMediumBrush" /> |
|||
<StaticResource x:Key="DataGridRowGroupHeaderForegroundBrush" |
|||
ResourceKey="SystemControlForegroundBaseHighBrush" /> |
|||
<StaticResource x:Key="DataGridRowInvalidBrush" |
|||
ResourceKey="SystemErrorTextColor" /> |
|||
<StaticResource x:Key="DataGridCellBackgroundBrush" |
|||
ResourceKey="SystemControlTransparentBrush" /> |
|||
<StaticResource x:Key="DataGridCellFocusVisualPrimaryBrush" |
|||
ResourceKey="SystemControlFocusVisualPrimaryBrush" /> |
|||
<StaticResource x:Key="DataGridCellFocusVisualSecondaryBrush" |
|||
ResourceKey="SystemControlFocusVisualSecondaryBrush" /> |
|||
<StaticResource x:Key="DataGridCellInvalidBrush" |
|||
ResourceKey="SystemErrorTextColor" /> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="DataGridCell"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridCellBackgroundBrush}" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Stretch" /> |
|||
<Setter Property="FontSize" Value="15" /> |
|||
<Setter Property="MinHeight" Value="32" /> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid x:Name="PART_CellRoot" |
|||
ColumnDefinitions="*,Auto" |
|||
Background="{TemplateBinding Background}"> |
|||
|
|||
<Rectangle x:Name="CurrencyVisual" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCurrencyVisualPrimaryBrush}" |
|||
StrokeThickness="1" /> |
|||
<Grid x:Name="FocusVisual" |
|||
IsHitTestVisible="False"> |
|||
<Rectangle HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualPrimaryBrush}" |
|||
StrokeThickness="2" /> |
|||
<Rectangle Margin="2" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualSecondaryBrush}" |
|||
StrokeThickness="1" /> |
|||
</Grid> |
|||
|
|||
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding Content}" |
|||
Margin="{TemplateBinding Padding}" |
|||
TextBlock.Foreground="{TemplateBinding Foreground}" |
|||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> |
|||
|
|||
<Rectangle x:Name="InvalidVisualElement" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellInvalidBrush}" |
|||
StrokeThickness="1" /> |
|||
|
|||
<Rectangle Name="PART_RightGridLine" |
|||
Grid.Column="1" |
|||
VerticalAlignment="Stretch" |
|||
Width="1" |
|||
Fill="{DynamicResource DataGridFillerColumnGridLinesBrush}" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridCell /template/ Rectangle#CurrencyVisual"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridCell /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridCell:current /template/ Rectangle#CurrencyVisual"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
<Style Selector="DataGrid:focus DataGridCell:current /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
<Style Selector="DataGridCell /template/ Rectangle#InvalidVisualElement"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridCell:invalid /template/ Rectangle#InvalidVisualElement"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader"> |
|||
<Setter Property="Foreground" Value="{DynamicResource DataGridColumnHeaderForegroundBrush}" /> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridColumnHeaderBackgroundBrush}" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="SeparatorBrush" Value="{DynamicResource DataGridGridLinesBrush}" /> |
|||
<Setter Property="Padding" Value="12,0,0,0" /> |
|||
<Setter Property="FontSize" Value="12" /> |
|||
<Setter Property="MinHeight" Value="32" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid Name="PART_ColumnHeaderRoot" |
|||
ColumnDefinitions="*,Auto" |
|||
Background="{TemplateBinding Background}"> |
|||
|
|||
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
Margin="{TemplateBinding Padding}"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*" /> |
|||
<ColumnDefinition MinWidth="32" |
|||
Width="Auto" /> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<ContentPresenter Content="{TemplateBinding Content}" /> |
|||
|
|||
<Path Name="SortIcon" |
|||
Grid.Column="1" |
|||
Fill="{TemplateBinding Foreground}" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
Stretch="Uniform" |
|||
Height="12" /> |
|||
</Grid> |
|||
|
|||
<Rectangle Name="VerticalSeparator" |
|||
Grid.Column="1" |
|||
Width="1" |
|||
VerticalAlignment="Stretch" |
|||
Fill="{TemplateBinding SeparatorBrush}" |
|||
IsVisible="{TemplateBinding AreSeparatorsVisible}" /> |
|||
|
|||
<Grid x:Name="FocusVisual" |
|||
IsHitTestVisible="False"> |
|||
<Rectangle x:Name="FocusVisualPrimary" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualPrimaryBrush}" |
|||
StrokeThickness="2" /> |
|||
<Rectangle x:Name="FocusVisualSecondary" |
|||
Margin="2" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualSecondaryBrush}" |
|||
StrokeThickness="1" /> |
|||
</Grid> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridColumnHeader:focus-visible /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader:pointerover /template/ Grid#PART_ColumnHeaderRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridColumnHeaderHoveredBackgroundColor}" /> |
|||
</Style> |
|||
<Style Selector="DataGridColumnHeader:pressed /template/ Grid#PART_ColumnHeaderRoot"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridColumnHeaderPressedBackgroundColor}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader:dragIndicator"> |
|||
<Setter Property="Opacity" Value="0.5" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader /template/ Path#SortIcon"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader:sortascending /template/ Path#SortIcon"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
<Setter Property="Data" Value="{StaticResource DataGridSortIconAscendingPath}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridColumnHeader:sortdescending /template/ Path#SortIcon"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
<Setter Property="Data" Value="{StaticResource DataGridSortIconDescendingPath}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRow"> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<DataGridFrozenGrid Name="PART_Root" |
|||
RowDefinitions="*,Auto,Auto" |
|||
ColumnDefinitions="Auto,*"> |
|||
|
|||
<Rectangle Name="BackgroundRectangle" |
|||
Grid.RowSpan="2" |
|||
Grid.ColumnSpan="2" /> |
|||
<Rectangle x:Name="InvalidVisualElement" |
|||
Grid.ColumnSpan="2" |
|||
Fill="{DynamicResource DataGridRowInvalidBrush}" /> |
|||
|
|||
<DataGridRowHeader Name="PART_RowHeader" |
|||
Grid.RowSpan="3" |
|||
DataGridFrozenGrid.IsFrozen="True" /> |
|||
<DataGridCellsPresenter Name="PART_CellsPresenter" |
|||
Grid.Column="1" |
|||
DataGridFrozenGrid.IsFrozen="True" /> |
|||
<DataGridDetailsPresenter Name="PART_DetailsPresenter" |
|||
Grid.Row="1" |
|||
Grid.Column="1" |
|||
Background="{DynamicResource DataGridDetailsPresenterBackgroundBrush}" /> |
|||
<Rectangle Name="PART_BottomGridLine" |
|||
Grid.Row="2" |
|||
Grid.Column="1" |
|||
HorizontalAlignment="Stretch" |
|||
Height="1" /> |
|||
|
|||
</DataGridFrozenGrid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRow /template/ Rectangle#InvalidVisualElement"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:invalid /template/ Rectangle#InvalidVisualElement"> |
|||
<Setter Property="Opacity" Value="0.4" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:invalid /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRow /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource SystemControlTransparentBrush}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:pointerover /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource SystemListLowColor}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:selected /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:selected:pointerover /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:selected:focus /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:selected:pointerover:focus /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundOpacity}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowHeader"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridRowHeaderBackgroundBrush}" /> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="SeparatorBrush" Value="{DynamicResource DataGridGridLinesBrush}" /> |
|||
<Setter Property="AreSeparatorsVisible" Value="False" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Grid x:Name="PART_Root" |
|||
RowDefinitions="*,*,Auto" |
|||
ColumnDefinitions="Auto,*"> |
|||
<Border Grid.RowSpan="3" |
|||
Grid.ColumnSpan="2" |
|||
BorderBrush="{TemplateBinding SeparatorBrush}" |
|||
BorderThickness="0,0,1,0"> |
|||
<Grid Background="{TemplateBinding Background}"> |
|||
<Rectangle x:Name="RowInvalidVisualElement" |
|||
Fill="{DynamicResource DataGridRowInvalidBrush}" |
|||
Stretch="Fill" /> |
|||
<Rectangle x:Name="BackgroundRectangle" |
|||
Stretch="Fill" /> |
|||
</Grid> |
|||
</Border> |
|||
<Rectangle x:Name="HorizontalSeparator" |
|||
Grid.Row="2" |
|||
Grid.ColumnSpan="2" |
|||
Height="1" |
|||
Margin="1,0,1,0" |
|||
HorizontalAlignment="Stretch" |
|||
Fill="{TemplateBinding SeparatorBrush}" |
|||
IsVisible="{TemplateBinding AreSeparatorsVisible}" /> |
|||
|
|||
<ContentPresenter Grid.RowSpan="2" |
|||
Grid.Column="1" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center" |
|||
Content="{TemplateBinding Content}" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowHeader /template/ Rectangle#RowInvalidVisualElement"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowHeader:invalid /template/ Rectangle#RowInvalidVisualElement"> |
|||
<Setter Property="Opacity" Value="0.4" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowHeader:invalid /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Opacity" Value="0" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowHeader /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource SystemControlTransparentBrush}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:pointerover DataGridRowHeader /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource SystemListLowColor}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowHeader:selected /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedUnfocusedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:pointerover DataGridRowHeader:selected /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredUnfocusedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowHeader:selected:focus /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedBackgroundOpacity}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRow:pointerover DataGridRowHeader:selected:focus /template/ Rectangle#BackgroundRectangle"> |
|||
<Setter Property="Fill" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundColor}" /> |
|||
<Setter Property="Opacity" Value="{DynamicResource DataGridRowSelectedHoveredBackgroundOpacity}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader"> |
|||
<Setter Property="Focusable" Value="False" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource DataGridRowGroupHeaderForegroundBrush}" /> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridRowGroupHeaderBackgroundBrush}" /> |
|||
<Setter Property="FontSize" Value="15" /> |
|||
<Setter Property="MinHeight" Value="32" /> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<DataGridFrozenGrid Name="PART_Root" |
|||
MinHeight="{TemplateBinding MinHeight}" |
|||
ColumnDefinitions="Auto,Auto,Auto,Auto,*" |
|||
RowDefinitions="*,Auto"> |
|||
|
|||
<Rectangle Name="IndentSpacer" |
|||
Grid.Column="1" /> |
|||
<ToggleButton Name="ExpanderButton" |
|||
Grid.Column="2" |
|||
Width="12" |
|||
Height="12" |
|||
Margin="12,0,0,0" |
|||
Background="{TemplateBinding Background}" |
|||
Foreground="{TemplateBinding Foreground}" |
|||
Focusable="False" /> |
|||
|
|||
<StackPanel Grid.Column="3" |
|||
Orientation="Horizontal" |
|||
VerticalAlignment="Center" |
|||
Margin="12,0,0,0"> |
|||
<TextBlock Name="PropertyNameElement" |
|||
Margin="4,0,0,0" |
|||
IsVisible="{TemplateBinding IsPropertyNameVisible}" |
|||
Foreground="{TemplateBinding Foreground}" /> |
|||
<TextBlock Margin="4,0,0,0" |
|||
Text="{Binding Key}" |
|||
Foreground="{TemplateBinding Foreground}" /> |
|||
<TextBlock Name="ItemCountElement" |
|||
Margin="4,0,0,0" |
|||
IsVisible="{TemplateBinding IsItemCountVisible}" |
|||
Foreground="{TemplateBinding Foreground}" /> |
|||
</StackPanel> |
|||
|
|||
<Rectangle x:Name="CurrencyVisual" |
|||
Grid.ColumnSpan="5" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCurrencyVisualPrimaryBrush}" |
|||
StrokeThickness="1" /> |
|||
<Grid x:Name="FocusVisual" |
|||
Grid.ColumnSpan="5" |
|||
IsHitTestVisible="False"> |
|||
<Rectangle HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualPrimaryBrush}" |
|||
StrokeThickness="2" /> |
|||
<Rectangle Margin="2" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Fill="Transparent" |
|||
IsHitTestVisible="False" |
|||
Stroke="{DynamicResource DataGridCellFocusVisualSecondaryBrush}" |
|||
StrokeThickness="1" /> |
|||
</Grid> |
|||
|
|||
<DataGridRowHeader Name="PART_RowHeader" |
|||
Grid.RowSpan="2" |
|||
DataGridFrozenGrid.IsFrozen="True" /> |
|||
|
|||
<Rectangle x:Name="PART_BottomGridLine" |
|||
Grid.Row="1" |
|||
Grid.ColumnSpan="5" |
|||
Height="1" /> |
|||
</DataGridFrozenGrid> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton"> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Grid.Column="0" |
|||
Width="12" |
|||
Height="12" |
|||
Background="Transparent" |
|||
HorizontalAlignment="Center" |
|||
VerticalAlignment="Center"> |
|||
<Path Fill="{TemplateBinding Foreground}" |
|||
HorizontalAlignment="Right" |
|||
VerticalAlignment="Center" |
|||
Stretch="Uniform" /> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton /template/ Path"> |
|||
<Setter Property="Data" Value="{StaticResource DataGridRowGroupHeaderIconOpenedPath}" /> |
|||
<Setter Property="Stretch" Value="Uniform" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton:checked /template/ Path"> |
|||
<Setter Property="Data" Value="{StaticResource DataGridRowGroupHeaderIconClosedPath}" /> |
|||
<Setter Property="Stretch" Value="UniformToFill" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader /template/ DataGridFrozenGrid#PART_Root"> |
|||
<Setter Property="Background" Value="{Binding $parent[DataGridRowGroupHeader].Background}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowGroupHeader:pointerover /template/ DataGridFrozenGrid#PART_Root"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridRowGroupHeaderHoveredBackgroundBrush}" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowGroupHeader:pressed /template/ DataGridFrozenGrid#PART_Root"> |
|||
<Setter Property="Background" Value="{DynamicResource DataGridRowGroupHeaderPressedBackgroundBrush}" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGridRowGroupHeader /template/ Rectangle#CurrencyVisual"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowGroupHeader /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="False" /> |
|||
</Style> |
|||
<Style Selector="DataGridRowGroupHeader:current /template/ Rectangle#CurrencyVisual"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
<Style Selector="DataGrid:focus DataGridRowGroupHeader:current /template/ Grid#FocusVisual"> |
|||
<Setter Property="IsVisible" Value="True" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DataGrid"> |
|||
<Setter Property="RowBackground" Value="Transparent" /> |
|||
<Setter Property="AlternatingRowBackground" Value="Transparent" /> |
|||
<Setter Property="HeadersVisibility" Value="Column" /> |
|||
<Setter Property="HorizontalScrollBarVisibility" Value="Auto" /> |
|||
<Setter Property="VerticalScrollBarVisibility" Value="Auto" /> |
|||
<Setter Property="SelectionMode" Value="Extended" /> |
|||
<Setter Property="GridLinesVisibility" Value="None" /> |
|||
<Setter Property="HorizontalGridLinesBrush" Value="{DynamicResource DataGridGridLinesBrush}" /> |
|||
<Setter Property="VerticalGridLinesBrush" Value="{DynamicResource DataGridGridLinesBrush}" /> |
|||
<Setter Property="DropLocationIndicatorTemplate"> |
|||
<Template> |
|||
<Rectangle Fill="{DynamicResource DataGridDropLocationIndicatorBackground}" |
|||
Width="2" /> |
|||
</Template> |
|||
</Setter> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<Border Background="{TemplateBinding Background}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
BorderBrush="{TemplateBinding BorderBrush}"> |
|||
<Grid RowDefinitions="Auto,*,Auto,Auto" |
|||
ColumnDefinitions="Auto,*,Auto"> |
|||
<Grid.Resources> |
|||
<ControlTemplate x:Key="TopLeftHeaderTemplate" |
|||
TargetType="DataGridColumnHeader"> |
|||
<Grid x:Name="TopLeftHeaderRoot" |
|||
RowDefinitions="*,*,Auto"> |
|||
<Border Grid.RowSpan="2" |
|||
BorderThickness="0,0,1,0" |
|||
BorderBrush="{DynamicResource DataGridGridLinesBrush}" /> |
|||
<Rectangle Grid.RowSpan="2" |
|||
VerticalAlignment="Bottom" |
|||
StrokeThickness="1" |
|||
Height="1" |
|||
Fill="{DynamicResource DataGridGridLinesBrush}" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
<ControlTemplate x:Key="TopRightHeaderTemplate" |
|||
TargetType="DataGridColumnHeader"> |
|||
<Grid x:Name="RootElement" /> |
|||
</ControlTemplate> |
|||
</Grid.Resources> |
|||
|
|||
<DataGridColumnHeader Name="PART_TopLeftCornerHeader" |
|||
Template="{StaticResource TopLeftHeaderTemplate}" /> |
|||
<DataGridColumnHeadersPresenter Name="PART_ColumnHeadersPresenter" |
|||
Grid.Column="1" |
|||
Grid.ColumnSpan="2" /> |
|||
<!--<DataGridColumnHeader Name="PART_TopRightCornerHeader" |
|||
Grid.Column="2" |
|||
Template="{StaticResource TopRightHeaderTemplate}" />--> |
|||
<!--<Rectangle Name="PART_ColumnHeadersAndRowsSeparator" |
|||
Grid.ColumnSpan="3" |
|||
VerticalAlignment="Bottom" |
|||
StrokeThickness="1" |
|||
Height="1" |
|||
Fill="{DynamicResource DataGridGridLinesBrush}" />--> |
|||
<Border Name="PART_ColumnHeadersAndRowsSeparator" |
|||
Grid.ColumnSpan="3" |
|||
Height="2" |
|||
VerticalAlignment="Bottom" |
|||
BorderThickness="0,0,0,1" |
|||
BorderBrush="{DynamicResource DataGridGridLinesBrush}" /> |
|||
|
|||
<DataGridRowsPresenter Name="PART_RowsPresenter" |
|||
Grid.Row="1" |
|||
Grid.RowSpan="2" |
|||
Grid.ColumnSpan="3" /> |
|||
<Rectangle Name="PART_BottomRightCorner" |
|||
Fill="{DynamicResource DataGridScrollBarsSeparatorBackground}" |
|||
Grid.Column="2" |
|||
Grid.Row="2" /> |
|||
<!--<Rectangle Name="BottomLeftCorner" |
|||
Fill="{DynamicResource DataGridScrollBarsSeparatorBackground}" |
|||
Grid.Row="2" |
|||
Grid.ColumnSpan="2" />--> |
|||
<ScrollBar Name="PART_VerticalScrollbar" |
|||
Orientation="Vertical" |
|||
Grid.Column="2" |
|||
Grid.Row="1" |
|||
Width="{DynamicResource ScrollBarSize}" /> |
|||
|
|||
<Grid Grid.Column="1" |
|||
Grid.Row="2" |
|||
ColumnDefinitions="Auto,*"> |
|||
<Rectangle Name="PART_FrozenColumnScrollBarSpacer" /> |
|||
<ScrollBar Name="PART_HorizontalScrollbar" |
|||
Grid.Column="1" |
|||
Orientation="Horizontal" |
|||
Height="{DynamicResource ScrollBarSize}" /> |
|||
</Grid> |
|||
<Border x:Name="PART_DisabledVisualElement" |
|||
Grid.ColumnSpan="3" |
|||
Grid.RowSpan="4" |
|||
IsHitTestVisible="False" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
CornerRadius="2" |
|||
Background="{DynamicResource DataGridDisabledVisualElementBackground}" |
|||
IsVisible="{Binding !$parent[DataGrid].IsEnabled}" /> |
|||
</Grid> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
</Styles> |
|||
@ -0,0 +1,4 @@ |
|||
Compat issues with assembly Avalonia.Markup.Xaml: |
|||
MembersMustExist : Member 'public Avalonia.Data.Binding Avalonia.Markup.Xaml.Templates.TreeDataTemplate.ItemsSource.get()' does not exist in the implementation but it does exist in the contract. |
|||
MembersMustExist : Member 'public void Avalonia.Markup.Xaml.Templates.TreeDataTemplate.ItemsSource.set(Avalonia.Data.Binding)' does not exist in the implementation but it does exist in the contract. |
|||
Total Issues: 2 |
|||
Loading…
Reference in new issue