add NavigationWindow style

This commit is contained in:
NaBian committed 2020-02-07 20:47:32 +08:00
1 parent 955894e265
commit 2544e84223
24 files changed
+293 -10

No files matched your search

@@ -0,0 +1,10 @@
<Window x:Class="HandyControlDemo.Window.NativeCommonWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStartupLocation="CenterScreen"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Title="{x:Static langs:Lang.Title}"
Height="450"
Width="800"
Icon="/HandyControlDemo;component/Resources/Img/icon.ico">
</Window>
@@ -0,0 +1,10 @@
namespace HandyControlDemo.Window
{
public partial class NativeCommonWindow
{
public NativeCommonWindow()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,10 @@
<NavigationWindow x:Class="HandyControlDemo.Window.NavigationWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStartupLocation="CenterScreen"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Title="{x:Static langs:Lang.Title}"
Height="450"
Width="800"
Icon="/HandyControlDemo;component/Resources/Img/icon.ico">
</NavigationWindow>
@@ -0,0 +1,56 @@
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using HandyControl.Tools.Extension;
namespace HandyControlDemo.Window
{
public partial class NavigationWindow
{
private readonly List<Page> _pageList;
public NavigationWindow()
{
InitializeComponent();
AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(Button_Click));
_pageList = new List<Page>();
for (var i = 0; i < 5; i++)
{
_pageList.Add(CreatePage(i));
}
Navigate(_pageList[0]);
}
private Page CreatePage(int index)
{
var indexStr = index.ToString();
var button = new Button
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Content = indexStr,
Width = 320,
Tag = indexStr
};
return new Page
{
Title = indexStr,
Content = button
};
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (e.OriginalSource is Button button && button.Tag is string tag)
{
var index = tag.Value<int>() + 1;
Navigate(index >= _pageList.Count ? _pageList[0] : _pageList[index]);
}
}
}
}