add Frame style

This commit is contained in:
NaBian committed 2020-02-08 11:08:44 +08:00
1 parent 2544e84223
commit ebde0bd42b
18 files changed
+192

No files matched your search

@@ -0,0 +1,9 @@
<UserControl x:Class="HandyControlDemo.UserControl.FrameDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
Background="{DynamicResource RegionBrush}">
<hc:TransitioningContentControl>
<Frame Margin="32" Width="500" Height="360" Name="FrameDemo" NavigationUIVisibility="Visible"/>
</hc:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,57 @@
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using HandyControl.Tools.Extension;
namespace HandyControlDemo.UserControl
{
public partial class FrameDemoCtl
{
private readonly List<Page> _pageList;
public FrameDemoCtl()
{
InitializeComponent();
AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(Button_Click));
_pageList = new List<Page>();
for (var i = 0; i < 5; i++)
{
_pageList.Add(CreatePage(i));
}
FrameDemo.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;
FrameDemo.Navigate(index >= _pageList.Count ? _pageList[0] : _pageList[index]);
}
}
}
}