enhance: optimized CoverView
This commit is contained in:
1 parent
508dfc0cf8
commit
12a01ac78e
7 files changed
+20
-20
No files matched your search
@@ -7860,7 +7860,7 @@
|
|||||||
<RowDefinition Height="16" />
|
<RowDefinition Height="16" />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Border x:Name="PART_Triangle" Visibility="Visible" Grid.Row="0" Width="30" Height="30" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.RowSpan="2">
|
<Border x:Name="PART_Triangle" Visibility="Visible" Grid.Row="0" Width="30" Height="30" BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.RowSpan="2">
|
||||||
<Border.RenderTransform>
|
<Border.RenderTransform>
|
||||||
<TransformGroup>
|
<TransformGroup>
|
||||||
<TranslateTransform X="5" Y="5" />
|
<TranslateTransform X="5" Y="5" />
|
||||||
@@ -7892,9 +7892,7 @@
|
|||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="hc:CoverView">
|
<ControlTemplate TargetType="hc:CoverView">
|
||||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||||
<ScrollViewer>
|
<WrapPanel x:Name="PART_Panel" />
|
||||||
<WrapPanel x:Name="PART_Panel" />
|
|
||||||
</ScrollViewer>
|
|
||||||
</Border>
|
</Border>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ namespace HandyControl.Controls
|
|||||||
"ShowSelectAllButton", typeof(bool), typeof(DataGridAttach), new PropertyMetadata(ValueBoxes.TrueBox));
|
"ShowSelectAllButton", typeof(bool), typeof(DataGridAttach), new PropertyMetadata(ValueBoxes.TrueBox));
|
||||||
|
|
||||||
public static void SetShowSelectAllButton(DependencyObject element, bool value)
|
public static void SetShowSelectAllButton(DependencyObject element, bool value)
|
||||||
=> element.SetValue(ShowSelectAllButtonProperty, value);
|
=> element.SetValue(ShowSelectAllButtonProperty, ValueBoxes.BooleanBox(value));
|
||||||
|
|
||||||
public static bool GetShowSelectAllButton(DependencyObject element)
|
public static bool GetShowSelectAllButton(DependencyObject element)
|
||||||
=> (bool) element.GetValue(ShowSelectAllButtonProperty);
|
=> (bool) element.GetValue(ShowSelectAllButtonProperty);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace HandyControl.Controls
|
|||||||
"AutoHide", typeof(bool), typeof(ScrollViewerAttach), new FrameworkPropertyMetadata(ValueBoxes.TrueBox, FrameworkPropertyMetadataOptions.Inherits));
|
"AutoHide", typeof(bool), typeof(ScrollViewerAttach), new FrameworkPropertyMetadata(ValueBoxes.TrueBox, FrameworkPropertyMetadataOptions.Inherits));
|
||||||
|
|
||||||
public static void SetAutoHide(DependencyObject element, bool value)
|
public static void SetAutoHide(DependencyObject element, bool value)
|
||||||
=> element.SetValue(AutoHideProperty, value);
|
=> element.SetValue(AutoHideProperty, ValueBoxes.BooleanBox(value));
|
||||||
|
|
||||||
public static bool GetAutoHide(DependencyObject element)
|
public static bool GetAutoHide(DependencyObject element)
|
||||||
=> (bool) element.GetValue(AutoHideProperty);
|
=> (bool) element.GetValue(AutoHideProperty);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
if (_selectedItem == null)
|
if (_selectedItem == null)
|
||||||
{
|
{
|
||||||
item.IsSelected = true;
|
item.SetCurrentValue(SelectableItem.IsSelectedProperty, ValueBoxes.TrueBox);
|
||||||
_selectedItem = item;
|
_selectedItem = item;
|
||||||
if (_viewContent != null)
|
if (_viewContent != null)
|
||||||
{
|
{
|
||||||
@@ -49,8 +49,8 @@ namespace HandyControl.Controls
|
|||||||
|
|
||||||
if (!Equals(_selectedItem, item))
|
if (!Equals(_selectedItem, item))
|
||||||
{
|
{
|
||||||
_selectedItem.IsSelected = false;
|
_selectedItem.SetCurrentValue(SelectableItem.IsSelectedProperty, ValueBoxes.FalseBox);
|
||||||
item.IsSelected = true;
|
item.SetCurrentValue(SelectableItem.IsSelectedProperty, ValueBoxes.TrueBox);
|
||||||
_selectedItem = item;
|
_selectedItem = item;
|
||||||
if (_viewContent != null)
|
if (_viewContent != null)
|
||||||
{
|
{
|
||||||
@@ -67,7 +67,7 @@ namespace HandyControl.Controls
|
|||||||
_viewContent.ContentTemplate = null;
|
_viewContent.ContentTemplate = null;
|
||||||
UpdateCoverViewContent(false);
|
UpdateCoverViewContent(false);
|
||||||
}
|
}
|
||||||
_selectedItem.IsSelected = false;
|
_selectedItem.SetCurrentValue(SelectableItem.IsSelectedProperty, ValueBoxes.FalseBox);
|
||||||
_selectedItem = null;
|
_selectedItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,6 +218,12 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
ItemsHost.Children.Remove(_viewContent);
|
ItemsHost.Children.Remove(_viewContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_selectedItem == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var total = _entryDic.Count + 1;
|
var total = _entryDic.Count + 1;
|
||||||
var totalRow = total / Groups + (total % Groups > 0 ? 1 : 0);
|
var totalRow = total / Groups + (total % Groups > 0 ? 1 : 0);
|
||||||
if (total <= Groups)
|
if (total <= Groups)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace HandyControl.Controls
|
|||||||
{
|
{
|
||||||
[TemplatePart(Name = ElementTriangle, Type = typeof(FrameworkElement))]
|
[TemplatePart(Name = ElementTriangle, Type = typeof(FrameworkElement))]
|
||||||
[TemplatePart(Name = ElementContent, Type = typeof(FrameworkElement))]
|
[TemplatePart(Name = ElementContent, Type = typeof(FrameworkElement))]
|
||||||
internal class CoverViewContent : ContentControl
|
public class CoverViewContent : ContentControl
|
||||||
{
|
{
|
||||||
private const string ElementTriangle = "PART_Triangle";
|
private const string ElementTriangle = "PART_Triangle";
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<RowDefinition Height="16"/>
|
<RowDefinition Height="16"/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Border x:Name="PART_Triangle" Visibility="Visible" Grid.Row="0" Width="30" Height="30" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.RowSpan="2">
|
<Border x:Name="PART_Triangle" Visibility="Visible" Grid.Row="0" Width="30" Height="30" BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.RowSpan="2">
|
||||||
<Border.RenderTransform>
|
<Border.RenderTransform>
|
||||||
<TransformGroup>
|
<TransformGroup>
|
||||||
<TranslateTransform X="5" Y="5"/>
|
<TranslateTransform X="5" Y="5"/>
|
||||||
@@ -62,13 +62,11 @@
|
|||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="hc:CoverView">
|
<ControlTemplate TargetType="hc:CoverView">
|
||||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||||
<ScrollViewer>
|
<WrapPanel x:Name="PART_Panel"/>
|
||||||
<WrapPanel x:Name="PART_Panel"/>
|
|
||||||
</ScrollViewer>
|
|
||||||
</Border>
|
</Border>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -7978,7 +7978,7 @@
|
|||||||
<RowDefinition Height="16" />
|
<RowDefinition Height="16" />
|
||||||
<RowDefinition />
|
<RowDefinition />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Border x:Name="PART_Triangle" Visibility="Visible" Grid.Row="0" Width="30" Height="30" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.RowSpan="2">
|
<Border x:Name="PART_Triangle" Visibility="Visible" Grid.Row="0" Width="30" Height="30" BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.RowSpan="2">
|
||||||
<Border.RenderTransform>
|
<Border.RenderTransform>
|
||||||
<TransformGroup>
|
<TransformGroup>
|
||||||
<TranslateTransform X="5" Y="5" />
|
<TranslateTransform X="5" Y="5" />
|
||||||
@@ -8010,9 +8010,7 @@
|
|||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="hc:CoverView">
|
<ControlTemplate TargetType="hc:CoverView">
|
||||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
|
||||||
<ScrollViewer>
|
<WrapPanel x:Name="PART_Panel" />
|
||||||
<WrapPanel x:Name="PART_Panel" />
|
|
||||||
</ScrollViewer>
|
|
||||||
</Border>
|
</Border>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
|
|||||||
Reference in new issue
Block a user