use Label item
This commit is contained in:
1 parent
ae050cb425
commit
68be369e39
5 files changed
+54
-24
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using FileManager_UWP.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
@@ -46,7 +47,7 @@ namespace FileManager_UWP.Controls {
|
||||
//TextBlock textBlock = (TextBlock)GetTemplateChild("LabelTextBlock");
|
||||
//textBlock.Text = "测试自定义控件\n";
|
||||
//listView.ItemsSource = ItemsSource;
|
||||
var itemsSource = ItemsSource as ObservableCollection<string>;
|
||||
var itemsSource = ItemsSource as ObservableCollection<LabelItem>;
|
||||
//textBlock.Text += itemsSource.Count().ToString();
|
||||
|
||||
//labelListCanvas.Children.Count;
|
||||
@@ -56,15 +57,16 @@ namespace FileManager_UWP.Controls {
|
||||
_expand_story_board.Stop();
|
||||
_expand_story_board.Children.Clear();
|
||||
int expanded_position = 0;
|
||||
foreach (string label in itemsSource) {
|
||||
foreach (LabelItem label in itemsSource) {
|
||||
Button b = new Button();
|
||||
b.Content = label;
|
||||
//b.SetValue(Canvas.LeftProperty, labelListCanvas.Children.Count * _collpse_distance);
|
||||
b.Content = label.tag;
|
||||
b.Background = new SolidColorBrush(label.color);
|
||||
b.SetValue(Canvas.LeftProperty, expanded_position);
|
||||
b.Style = (Style)genericResourceDictionary["LabelButtonStyle"];
|
||||
b.Click += B_Click;
|
||||
|
||||
DoubleAnimation collpse_animate = new DoubleAnimation();
|
||||
collpse_animate.From = labelListCanvas.Children.Count * 22;
|
||||
collpse_animate.From = null; // labelListCanvas.Children.Count * 22;
|
||||
collpse_animate.To = expanded_position;
|
||||
collpse_animate.Duration = _animate_during;
|
||||
collpse_animate.Completed += Animate_Completed;
|
||||
@@ -73,17 +75,24 @@ namespace FileManager_UWP.Controls {
|
||||
Storyboard.SetTargetProperty(collpse_animate, "(Canvas.Left)");
|
||||
|
||||
DoubleAnimation expand_animate = new DoubleAnimation();
|
||||
expand_animate.From = collpse_animate.To;
|
||||
expand_animate.To = collpse_animate.From;
|
||||
expand_animate.From = null; // expanded_position;
|
||||
expand_animate.To = labelListCanvas.Children.Count * 22;
|
||||
expand_animate.Duration = _animate_during;
|
||||
expand_animate.Completed += Animate_Completed;
|
||||
_expand_story_board.Children.Add(expand_animate);
|
||||
Storyboard.SetTarget(expand_animate, b);
|
||||
Storyboard.SetTargetProperty(expand_animate, "(Canvas.Left)");
|
||||
|
||||
expanded_position += label.Count() * 14 + 20;
|
||||
expanded_position += label.tag.Count() * 14 + 20;
|
||||
labelListCanvas.Children.Add(b);
|
||||
}
|
||||
measure();
|
||||
LabelListCanvas_PointerExited(null, null);
|
||||
}
|
||||
|
||||
private void B_Click(object sender, RoutedEventArgs e) {
|
||||
Button b = sender as Button;
|
||||
Debug.WriteLine(b.Content);
|
||||
}
|
||||
|
||||
private void Animate_Completed(object sender, object e) {
|
||||
@@ -99,18 +108,14 @@ namespace FileManager_UWP.Controls {
|
||||
|
||||
private void LabelListCanvas_PointerExited(object sender, PointerRoutedEventArgs e) {
|
||||
_expand_story_board.Begin();
|
||||
Debug.WriteLine(labelListCanvas.Width.ToString() + "," + labelListCanvas.Height.ToString());
|
||||
}
|
||||
|
||||
private void LabelListCanvas_PointerEntered(object sender, PointerRoutedEventArgs e) {
|
||||
_collpse_story_board.Begin();
|
||||
//labelListCanvas.Width = labelListCanvas.ActualWidth;
|
||||
//labelListCanvas.Height = 20;
|
||||
Debug.WriteLine(labelListCanvas.Width.ToString() + "," + labelListCanvas.Height.ToString());
|
||||
}
|
||||
|
||||
private void init() {
|
||||
var itemsSource = ItemsSource as ObservableCollection<string>;
|
||||
var itemsSource = ItemsSource as ObservableCollection<LabelItem>;
|
||||
itemsSource.CollectionChanged += ItemsSource_CollectionChanged;
|
||||
Button labelListButton = (Button)GetTemplateChild("LabelListPresenter");
|
||||
labelListButton.PointerEntered += LabelListCanvas_PointerEntered;
|
||||
|
||||
Reference in new issue
Block a user