-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
110 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Controls.Primitives; | ||
using System.Collections; | ||
using System.Collections.Specialized; | ||
using Microsoft.Phone.Controls; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace CustomControls | ||
{ | ||
using ElementType = Sbbs.BoardViewModel; | ||
using CollectionType = ObservableCollection<Sbbs.BoardViewModel>; | ||
public class RecursiveListBox : ListBox | ||
{ | ||
// 浏览历史 | ||
private Stack<CollectionType> history = new Stack<CollectionType>(); | ||
|
||
// 叶子结点点击事件 | ||
public delegate void OnLeafItemTap(object sender, SelectionChangedEventArgs e); | ||
public event OnLeafItemTap LeafItemTap; | ||
|
||
// 捕捉选择事件 | ||
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) | ||
{ | ||
if (e.AddedItems.Count == 1) | ||
{ | ||
// 清除选择 | ||
(sender as ListBox).SelectedIndex = -1; | ||
|
||
ElementType board = e.AddedItems[0] as ElementType; | ||
if (board.Leaf && LeafItemTap != null) | ||
{ | ||
// 叶子结点直接触发事件 | ||
LeafItemTap(sender, e); | ||
} | ||
else if (!board.Leaf) | ||
{ | ||
// 非叶子结点切换视角 | ||
if (board.EnglishName == "..") | ||
{ | ||
ItemsSource = history.Pop() as CollectionType; | ||
} | ||
else | ||
{ | ||
history.Push(ItemsSource as CollectionType); | ||
ItemsSource = board.Boards; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public RecursiveListBox() | ||
{ | ||
DefaultStyleKey = typeof(RecursiveListBox); | ||
SelectionChanged += ListBox_SelectionChanged; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters