提交 e75b36f0 编写于 作者: P Pomianowski

Initial changes

上级 c30c020b
此差异由.gitattributes 抑制。
文件已添加
此差异由.gitattributes 抑制。
......@@ -370,4 +370,4 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.
defined by the Mozilla Public License, v. 2.0.
\ No newline at end of file
# WPF UI
[Created with ❤ in Poland by lepo.co](https://dev.lepo.co/)
A simple way to make your application written in WPF keep up with modern design trends. Library changes the base elements like Window, Page or Button, and also includes additional controls like Navigation, ToggleButton or Snackbar.
## Microsoft Property
Design of the interface, choice of colors and the appearance of the controls were inspired by projects made by Microsoft for Windows 11.
The WPFUI.Demo app includes icons from Shell32 for Windows 11. These icons are the legal property of Microsoft and you may not use them in your own app without permission. They are used here as an example of creating tools for Microsoft systems.
## What's included?
| Name| Framework | Build Status |
| --- | --- | --- |
| **WPFUI**<br />Library that allows you to use all features in your own application | .NET 5.0 Windows,<br/>.NET Core 3.1<br/>.NET Framework 4.8 | [![Build status](https://github.com/rapiddev/MaterialWPF/workflows/CI/badge.svg)](https://github.com/rapiddev/MaterialWPF/actions) |
| **WPFUI.Demo**<br />An application written in WPF .NET 5 where you can test the features. | .NET 5.0 Windows | [![Build status](https://github.com/rapiddev/MaterialWPF/workflows/CI/badge.svg)](https://github.com/rapiddev/MaterialWPF/actions) |
## Custom controls
| Control | Namespace | Description |
| --- | --- | --- |
| **Button** | [WPFUI.Controls](https://github.com/lepoco/WPFUI/tree/master/WPFUI/Controls) | Class with which you can send a Toast to the Windows notification center. |
| **CardAction** | [WPFUI.Controls](https://github.com/lepoco/WPFUI/tree/master/WPFUI/Controls) | . |
| **CardCollapse** | [WPFUI.Controls](https://github.com/lepoco/WPFUI/tree/master/WPFUI/Controls) | A control that you can display in the middle of the application, e.g. with a "Save as" information or whatever... |
| **CardProfile** | [WPFUI.Controls](https://github.com/lepoco/WPFUI/tree/master/WPFUI/Controls) | A button that navigates to the browser window. |
| **CodeBlock** | [WPFUI.Controls](https://github.com/lepoco/WPFUI/tree/master/WPFUI/Controls) | Prepared TextBlock with "Glyph" attribute with which you can select an icon. |
| **Hyperlink** | [WPFUI.Controls](https://github.com/lepoco/WPFUI/tree/master/WPFUI/Controls) | A control that opens a website. |
| **Icon** | [WPFUI.Controls](https://github.com/lepoco/WPFUI/tree/master/WPFUI/Controls) | A collection of all [Micon](https://github.com/xtoolkit/Micon) font glyphs that you can use in an application. |
| **Navigation** | [WPFUI.Controls](https://github.com/lepoco/WPFUI/tree/master/WPFUI/Controls) | Navigation styled as UWP apps. |
| **NavigationBubble** | [WPFUI.Controls](https://github.com/lepoco/WPFUI/tree/master/WPFUI/Controls) | Navigation styled as Windows 11 Store app |
| **NavigationFluent** | [WPFUI.Controls](https://github.com/lepoco/WPFUI/tree/master/WPFUI/Controls) | Navigation styled as Windows 11 Settings app. |
| **WindowNavigation** | [WPFUI.Controls](https://github.com/lepoco/WPFUI/tree/master/WPFUI/Controls) | A set of buttons that can replace the default window navigation, giving it a new, modern look. |
## Custom tools
| Class | Namespace | Description |
| --- | --- | --- |
| **Theme** | [WPFUI](https://github.com/lepoco/WPFUI/tree/master/WPFUI) | Class with which you can change and control the application theme. |
\ No newline at end of file
<Application x:Class="WPFUI.DEMO.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFUI.DEMO"
StartupUri="MainWindow.xaml">
<Application
x:Class="WPFUI.Demo.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Views/Container.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/WPFUI;component/Styles/Theme/Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/WPFUI;component/Styles/WPFUI.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows;
namespace WPFUI.DEMO
namespace WPFUI.Demo
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
WPFUI.Theme.WatchSystemTheme();
}
}
}
此差异由.gitattributes 抑制。
此差异由.gitattributes 抑制。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WPFUI.DEMO
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
<Window
x:Class="WPFUI.Demo.Views.Container"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Demo.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wpfui="clr-namespace:WPFUI.Controls;assembly=WPFUI"
Title="WPF UI"
Width="1100"
Height="600"
MinWidth="900"
MinHeight="450"
Style="{StaticResource MUNavWindowRounded}"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<wpfui:WindowNavigation Grid.Row="0" ApplicationNavigation="True" />
<Grid Grid.Row="1" Margin="6,6,12,6">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<wpfui:CardProfile Margin="4,0,4,40" Source="pack://application:,,,/Assets/mwpf_icon_full.png">
<StackPanel>
<TextBlock FontWeight="Medium" Text="WPF UI" />
<TextBlock Foreground="{DynamicResource WUForegroundSecondary}" Text="Fluent Design System" />
</StackPanel>
</wpfui:CardProfile>
<wpfui:NavigationFluent
x:Name="RootNavigation"
Grid.Row="1"
Grid.Column="0"
Margin="0,0,12,0" />
<Frame
x:Name="RootFrame"
Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1" />
</Grid>
</Grid>
</Window>
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Collections.ObjectModel;
using System.Windows;
using WPFUI.Common;
namespace WPFUI.Demo.Views
{
/// <summary>
/// Interaction logic for Container.xaml
/// </summary>
public partial class Container : Window
{
private const string AssetsPath = "pack://application:,,,/Assets/";
public Container()
{
InitializeComponent();
this.InitializeNavigation();
}
private void InitializeNavigation()
{
RootNavigation.Frame = RootFrame;
RootNavigation.Items = new ObservableCollection<NavItem>
{
new NavItem { ImageUri = AssetsPath + "microsoft-shell-desktop.ico", Name = "Dashboard", Tag = "dashboard", Type = typeof(Pages.Dashboard)},
new NavItem { ImageUri = AssetsPath + "microsoft-shell-workspace.ico", Name = "Controls", Tag = "controls", Type = typeof(Pages.Controls)},
new NavItem { ImageUri = AssetsPath + "microsoft-shell-monitor.ico", Name = "Windows", Tag = "windows", Type = typeof(Pages.WindowsPage)},
new NavItem { ImageUri = AssetsPath + "microsoft-shell-star.ico", Name = "Icons", Tag = "icons", Type = typeof(Pages.Icons)},
new NavItem { ImageUri = AssetsPath + "microsoft-shell-colors.ico", Name = "Colors", Tag = "colors", Type = typeof(Pages.Colors)},
new NavItem { ImageUri = AssetsPath + "microsoft-shell-settings.ico", Name = "Settings", Tag = "settings", Type = typeof(Pages.Settings)}
};
//RootNavigation.Footer = new ObservableCollection<NavItem>
//{
// new NavItem { Icon = MUIcon.GridView, Name = "Settings", Tag = "settings", Type = typeof(Pages.Settings)}
//};
//rootNavigation.OnNavigate = OnNavigate;
RootNavigation.Navigate("dashboard");
}
}
}
<Page
x:Class="WPFUI.Demo.Views.Pages.Colors"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Demo.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wpfui="clr-namespace:WPFUI.Controls;assembly=WPFUI"
Title="Colors"
d:DesignHeight="450"
d:DesignWidth="800"
Style="{StaticResource WUPage}"
mc:Ignorable="d">
<Grid Margin="0,0,0,12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Margin="0,0,0,18"
FontSize="20"
FontWeight="Medium"
Text="Colors" />
<StackPanel Grid.Row="1">
<wpfui:CardCollapse
Title="Default palette"
Margin="0,0,0,8"
Glyph="Color"
IsContentVisible="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Border
Width="40"
Height="40"
Margin="2"
Background="{DynamicResource PalettePrimary}"
CornerRadius="6" />
<Border
Width="40"
Height="40"
Margin="2"
Background="{DynamicResource PaletteRed}"
CornerRadius="6" />
<Border
Width="40"
Height="40"
Margin="2"
Background="{DynamicResource PalettePink}"
CornerRadius="6" />
<Border
Width="40"
Height="40"
Margin="2"
Background="{DynamicResource PalettePurple}"
CornerRadius="6" />
<Border
Width="40"
Height="40"
Margin="2"
Background="{DynamicResource PaletteDeepPurple}"
CornerRadius="6" />
<Border
Width="40"
Height="40"
Margin="2"
Background="{DynamicResource PaletteIndigo}"
CornerRadius="6" />
<Border
Width="40"
Height="40"
Margin="2"
Background="{DynamicResource PaletteBlue}"
CornerRadius="6" />
</StackPanel>
</Grid>
</wpfui:CardCollapse>
<wpfui:CardCollapse
Title="Theme colors"
Margin="0,0,0,8"
Glyph="Color"
IsContentVisible="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal">
<Border
Width="40"
Height="40"
Margin="2"
Background="{DynamicResource WUBorder}"
CornerRadius="6" />
<Border
Width="40"
Height="40"
Margin="2"
Background="{DynamicResource WUForeground}"
CornerRadius="6" />
</StackPanel>
</Grid>
</wpfui:CardCollapse>
</StackPanel>
</Grid>
</Page>
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows.Controls;
namespace WPFUI.Demo.Views.Pages
{
/// <summary>
/// Interaction logic for Colors.xaml
/// </summary>
public partial class Colors : Page
{
public Colors()
{
InitializeComponent();
}
}
}
<Page
x:Class="WPFUI.Demo.Views.Pages.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Demo.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="Controls"
d:DesignHeight="450"
d:DesignWidth="800"
Style="{StaticResource WUPage}"
mc:Ignorable="d">
<Grid Margin="0,0,0,12">
<TextBlock
FontSize="20"
FontWeight="Medium"
Text="Controls" />
</Grid>
</Page>
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows.Controls;
namespace WPFUI.Demo.Views.Pages
{
/// <summary>
/// Interaction logic for Controls.xaml
/// </summary>
public partial class Controls : Page
{
public Controls()
{
InitializeComponent();
}
}
}
<Page
x:Class="WPFUI.Demo.Views.Pages.Dashboard"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Demo.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wpfui="clr-namespace:WPFUI.Controls;assembly=WPFUI"
Title="Dashboard"
d:DesignHeight="450"
d:DesignWidth="800"
Style="{StaticResource WUPageScrollable}"
mc:Ignorable="d">
<Grid Margin="0,0,0,12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
FontSize="20"
FontWeight="Medium"
Text="Dashboard" />
<Grid Grid.Row="1" Margin="0,18">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Width="70" Source="pack://application:,,,/Assets/microsoft-icon-store.png" />
<StackPanel
Grid.Column="1"
Margin="12,0,0,0"
VerticalAlignment="Center">
<TextBlock
Margin="0,0,0,4"
FontSize="16"
FontWeight="Medium"
Text="Compatible" />
<TextBlock Foreground="{DynamicResource WUForegroundSecondary}" Text="With Windows 10 and 11" />
</StackPanel>
</Grid>
<Grid Grid.Column="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<wpfui:Icon FontSize="14" Glyph="Health" />
<StackPanel
Grid.Column="1"
Margin="12,0,0,0"
VerticalAlignment="Center">
<TextBlock
Margin="0,0,0,4"
FontSize="11"
FontWeight="Medium"
Text="Intuitive and powerful" />
<TextBlock
FontSize="10"
Foreground="{DynamicResource WUForegroundSecondary}"
Text="Open-source library for .NET" />
</StackPanel>
</Grid>
<Grid Grid.Column="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<wpfui:Icon FontSize="14" Glyph="CalligraphyPen" />
<StackPanel
Grid.Column="1"
Margin="12,0,0,0"
VerticalAlignment="Center">
<TextBlock
Margin="0,0,0,4"
FontSize="11"
FontWeight="Medium"
Text="Engaging and immersive" />
<TextBlock
FontSize="10"
Foreground="{DynamicResource WUForegroundSecondary}"
Text="Be part of the Windows design revolution" />
</StackPanel>
</Grid>
</Grid>
<Grid Grid.Row="2">
<StackPanel>
<wpfui:CardAction
Margin="0,0,0,8"
Click="ActionCardComponentsClick"
Glyph="Design">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
FontWeight="Medium"
Text="Controls" />
<TextBlock
FontSize="10"
Foreground="{DynamicResource WUForegroundSecondary}"
Text="Check out the available custom components" />
</StackPanel>
</wpfui:CardAction>
<wpfui:CardAction
Margin="0,0,0,8"
Click="ActionCardIconsClick"
Glyph="Calories">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
FontWeight="Medium"
Text="Icons" />
<TextBlock
FontSize="10"
Foreground="{DynamicResource WUForegroundSecondary}"
Text="Easy to use and elegant, inspired by the default Windows icons." />
</StackPanel>
</wpfui:CardAction>
<wpfui:CardAction
Margin="0,0,0,8"
Click="ActionCardColorsClick"
Glyph="Color">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
FontWeight="Medium"
Text="Color palette" />
<TextBlock
FontSize="10"
Foreground="{DynamicResource WUForegroundSecondary}"
Text="A small set of colors in line with those presented by Microsoft." />
</StackPanel>
</wpfui:CardAction>
<wpfui:CardCollapse
Title="Find out more!"
Margin="0,0,0,8"
Glyph="Info">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
FontWeight="Medium"
Text="Color palette" />
<TextBlock
FontSize="10"
Foreground="{DynamicResource WUForegroundSecondary}"
Text="A small set of colors in line with those presented by Microsoft." />
</StackPanel>
</wpfui:CardCollapse>
<wpfui:Hyperlink
Margin="0,0,0,4"
Content="Source code and help on GitHub"
Glyph="GitHub"
NavigateUri="https://github.com/lepoco/wpfui" />
<wpfui:Hyperlink
Content="Project library on NuGet"
Glyph="Microsoft"
NavigateUri="https://github.com/lepoco/wpfui" />
</StackPanel>
</Grid>
</Grid>
</Page>
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows.Controls;
namespace WPFUI.Demo.Views.Pages
{
/// <summary>
/// Interaction logic for Dashboard.xaml
/// </summary>
public partial class Dashboard : Page
{
public Dashboard()
{
InitializeComponent();
}
public void ActionCardIconsClick()
{
(App.Current.MainWindow as Container).RootNavigation.Navigate("icons");
}
public void ActionCardComponentsClick()
{
(App.Current.MainWindow as Container).RootNavigation.Navigate("controls");
}
public void ActionCardColorsClick()
{
(App.Current.MainWindow as Container).RootNavigation.Navigate("colors");
}
}
}
<Page
x:Class="WPFUI.Demo.Views.Pages.Icons"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Demo.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wpfui="clr-namespace:WPFUI.Controls;assembly=WPFUI"
Title="Icons"
d:DesignHeight="450"
d:DesignWidth="800"
Style="{StaticResource WUPage}"
mc:Ignorable="d">
<Grid Margin="0,0,0,12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Margin="0,0,0,18"
FontSize="20"
FontWeight="Medium"
Text="Icons" />
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ScrollViewer
Grid.Column="0"
Margin="6,0,0,0"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Visible"
Style="{StaticResource WUScrollViewer}">
<ItemsControl
x:Name="IconsItemsControl"
VerticalAlignment="Top"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="7" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="local:DisplayableIcon">
<Border
Width="80"
Height="80"
Margin="2"
Background="{DynamicResource WUElement}"
BorderThickness="0"
CornerRadius="6"
Cursor="Hand"
MouseDown="Border_MouseDown"
Tag="{Binding Path=ID, Mode=OneTime}">
<wpfui:Icon FontSize="25" Glyph="{Binding Path=Icon, Mode=OneTime}" />
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<Grid Grid.Column="1" MinWidth="150">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<wpfui:Icon
x:Name="IconActiveIcon"
Grid.Row="0"
VerticalAlignment="Center"
FontSize="100"
Glyph="None" />
<StackPanel Grid.Row="1" Margin="8">
<TextBlock
x:Name="TextIconName"
HorizontalAlignment="Center"
FontWeight="Bold" />
<TextBlock
x:Name="TextMiconGlyph"
Margin="0,0,0,12"
HorizontalAlignment="Center"
Foreground="{DynamicResource WUAccent}" />
<Border
VerticalAlignment="Top"
Background="{DynamicResource WUElement}"
CornerRadius="6">
<TextBlock
Padding="12"
HorizontalAlignment="Center"
FontSize="10"
TextWrapping="WrapWithOverflow">
<TextBlock Foreground="{DynamicResource PaletteTeal}" Text="&lt;" />
<TextBlock Foreground="{DynamicResource PaletteDeepOrange}" Text="wpfui:Icon" />
<TextBlock Foreground="{DynamicResource WUAccent}" Text=" Glyph" />
<TextBlock Foreground="{DynamicResource PaletteTeal}" Text="=" />
<TextBlock Foreground="{DynamicResource PaletteDeepOrange}" Text="&quot;" />
<TextBlock
x:Name="TextIconCodeName"
Foreground="{DynamicResource WUForeground}"
Text="Accept" />
<TextBlock Foreground="{DynamicResource PaletteDeepOrange}" Text="&quot;" />
<TextBlock Foreground="{DynamicResource PaletteTeal}" Text=" /&gt;" />
</TextBlock>
</Border>
</StackPanel>
</Grid>
</Grid>
</Grid>
</Page>
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
using WPFUI.Common;
namespace WPFUI.Demo.Views.Pages
{
public struct DisplayableIcon
{
public int ID { get; set; }
public string Name { get; set; }
public string Code { get; set; }
public MiconIcon Icon { get; set; }
}
/// <summary>
/// Interaction logic for Icons.xaml
/// </summary>
public partial class Icons : Page
{
private DisplayableIcon _activeGlyph;
private List<DisplayableIcon> icons;
public Icons()
{
InitializeComponent();
this.FillIcons();
}
private async void FillIcons()
{
icons = new List<DisplayableIcon> { };
DataContext = this;
await Task.Run(() =>
{
int id = 0;
foreach (string iconName in Enum.GetNames(typeof(MiconIcon)))
{
MiconIcon icon = (MiconIcon)Enum.Parse(typeof(MiconIcon), iconName);
//System.Diagnostics.Debug.WriteLine(icon);
icons.Add(new DisplayableIcon
{
ID = id++,
Name = iconName,
Icon = icon,
Code = ((int)MiconGlyph.ToGlyph(icon)).ToString("X4")
});
}
App.Current.Dispatcher.Invoke(() =>
{
IconsItemsControl.ItemsSource = icons;
if (icons.Count > 4)
{
this._activeGlyph = icons[4];
this.ChangeGlyps();
}
});
Thread.Sleep(1000);
App.Current.Dispatcher.Invoke(() =>
{
//gridLoading.Visibility = Visibility.Hidden;
});
});
}
private void ChangeGlyps()
{
TextIconName.Text = this._activeGlyph.Name;
TextIconCodeName.Text = this._activeGlyph.Name;
IconActiveIcon.Glyph = this._activeGlyph.Icon;
TextMiconGlyph.Text = "\\u" + this._activeGlyph.Code;
}
private void Border_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
int id = Int32.Parse((sender as Border).Tag.ToString());
this._activeGlyph = icons[id];
this.ChangeGlyps();
}
}
}
<Page
x:Class="WPFUI.Demo.Views.Pages.Settings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Demo.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wpfui="clr-namespace:WPFUI.Controls;assembly=WPFUI"
Title="Settings"
d:DesignHeight="450"
d:DesignWidth="800"
Style="{StaticResource WUPage}"
mc:Ignorable="d">
<Grid Margin="0,0,0,12">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock
FontSize="20"
FontWeight="Medium"
Text="Settings" />
<StackPanel Grid.Row="2" HorizontalAlignment="Right">
<wpfui:Button Content="Save" />
</StackPanel>
</Grid>
</Page>
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows.Controls;
namespace WPFUI.Demo.Views.Pages
{
/// <summary>
/// Interaction logic for Settings.xaml
/// </summary>
public partial class Settings : Page
{
public Settings()
{
InitializeComponent();
}
}
}
<Page
x:Class="WPFUI.Demo.Views.Pages.WindowsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Demo.Views.Pages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wpfui="clr-namespace:WPFUI.Controls;assembly=WPFUI"
Title="WindowsPage"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid Margin="0,0,0,12">
<StackPanel>
<wpfui:CardAction
Margin="0,0,0,8"
Click="ActionCardBubbleNavigation"
Glyph="Calories">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
FontWeight="Medium"
Text="Bubble Navigation" />
<TextBlock
FontSize="10"
Foreground="{DynamicResource WUForegroundSecondary}"
Text="Modern, round icons stylized as Windows Store and Xbox App" />
</StackPanel>
</wpfui:CardAction>
</StackPanel>
</Grid>
</Page>
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows.Controls;
namespace WPFUI.Demo.Views.Pages
{
/// <summary>
/// Interaction logic for WindowsPage.xaml
/// </summary>
public partial class WindowsPage : Page
{
public WindowsPage()
{
InitializeComponent();
}
public void ActionCardBubbleNavigation()
{
Windows.Bubble bubbleWindow = new();
bubbleWindow.Show();
}
}
}
<Window
x:Class="WPFUI.Demo.Views.Windows.Bubble"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Demo.Views.Windows"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wpfui="clr-namespace:WPFUI.Controls;assembly=WPFUI"
Title="Bubble"
Width="800"
Height="450"
Style="{StaticResource MUNavWindowRounded}"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<wpfui:WindowNavigation Grid.Row="0" ApplicationNavigation="False" />
<Grid Grid.Row="0">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center">
<TextBlock Text="Windows Store" />
</StackPanel>
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<wpfui:NavigationBubble
x:Name="RootNavigation"
Grid.Column="0"
Margin="0,0,12,0" />
<Border
Grid.Column="1"
Background="{DynamicResource WUElement}"
CornerRadius="8,0,0,0">
<Frame x:Name="RootFrame" />
</Border>
</Grid>
</Grid>
</Window>
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Collections.ObjectModel;
using System.Windows;
using WPFUI.Common;
namespace WPFUI.Demo.Views.Windows
{
/// <summary>
/// Interaction logic for Bubble.xaml
/// </summary>
public partial class Bubble : Window
{
public Bubble()
{
InitializeComponent();
this.InitializeNavigation();
}
private void InitializeNavigation()
{
RootNavigation.Frame = RootFrame;
RootNavigation.Items = new ObservableCollection<NavItem>
{
new NavItem { Icon = MiconIcon.Accounts, Name = "Dashboard", Tag = "dashboard", Type = typeof(Pages.Dashboard)},
new NavItem { Icon = MiconIcon.Accounts, Name = "Controls", Tag = "controls", Type = typeof(Pages.Controls)},
new NavItem { Icon = MiconIcon.Accounts, Name = "Icons", Tag = "icons", Type = typeof(Pages.Icons)},
new NavItem { Icon = MiconIcon.Accounts, Name = "Colors", Tag = "colors", Type = typeof(Pages.Colors)}
};
RootNavigation.Navigate("dashboard");
}
}
}
<Window x:Class="WPFUI.DEMO.MainWindow"
<Window x:Class="WPFUI.Demo.Views.Windows.Fluent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WPFUI.DEMO"
xmlns:local="clr-namespace:WPFUI.Demo.Views.Windows"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
Title="Fluent" Height="450" Width="800">
<Grid>
</Grid>
</Window>
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows;
namespace WPFUI.Demo.Views.Windows
{
/// <summary>
/// Interaction logic for Fluent.xaml
/// </summary>
public partial class Fluent : Window
{
public Fluent()
{
InitializeComponent();
}
}
}
......@@ -4,6 +4,58 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<StartupObject>WPFUI.Demo.App</StartupObject>
<ApplicationIcon>mwpf_icon.ico</ApplicationIcon>
<AssemblyName>WPF UI - Demo App</AssemblyName>
</PropertyGroup>
<ItemGroup>
<None Remove="Assets\DDORes_2169.ico" />
<None Remove="Assets\info.ico" />
<None Remove="Assets\microsoft-icon-store.png" />
<None Remove="Assets\microsoft-icon-tips.png" />
<None Remove="Assets\microsoft-shell-colors.ico" />
<None Remove="Assets\microsoft-shell-computer.ico" />
<None Remove="Assets\microsoft-shell-desktop.ico" />
<None Remove="Assets\microsoft-shell-info.ico" />
<None Remove="Assets\microsoft-shell-monitor.ico" />
<None Remove="Assets\microsoft-shell-settings.ico" />
<None Remove="Assets\microsoft-shell-star.ico" />
<None Remove="Assets\microsoft-shell-switch.ico" />
<None Remove="Assets\microsoft-shell-tablet.ico" />
<None Remove="Assets\microsoft-shell-user.ico" />
<None Remove="Assets\microsoft-shell-videos.ico" />
<None Remove="Assets\microsoft-shell-warning.ico" />
<None Remove="Assets\microsoft-shell-workspace.ico" />
<None Remove="Assets\mwpf_icon_full.png" />
<None Remove="Assets\pc.ico" />
<None Remove="Assets\settings.ico" />
<None Remove="Assets\store.png" />
<None Remove="Assets\switch.ico" />
<None Remove="Assets\tablet.ico" />
<None Remove="Assets\test_icon.ico" />
<None Remove="Assets\tips.png" />
<None Remove="Assets\user.ico" />
<None Remove="Assets\videos.ico" />
<None Remove="Assets\warning.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\microsoft-shell-colors.ico" />
<Resource Include="Assets\microsoft-shell-monitor.ico" />
<Resource Include="Assets\microsoft-shell-star.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WPFUI\WPFUI.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\microsoft-icon-store.png" />
<Resource Include="Assets\microsoft-shell-desktop.ico" />
<Resource Include="Assets\microsoft-shell-settings.ico" />
<Resource Include="Assets\microsoft-shell-workspace.ico" />
<Resource Include="Assets\mwpf_icon_full.png" />
</ItemGroup>
</Project>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WPFUI
{
public class Class1
{
}
}
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
namespace WPFUI.Common
{
public enum ElementColor
{
Unknown,
Primary,
Secondary
}
}
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
namespace WPFUI.Common
{
enum IconType
{
Fluent,
Micon
}
}
此差异已折叠。
此差异已折叠。
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System;
using System.ComponentModel;
using System.Windows.Media.Imaging;
namespace WPFUI.Common
{
/// <summary>
/// An interactive element that is a block in the menu for the <see cref="WPFUI.Controls.Navigation"/> control.
/// </summary>
public class NavItem : INotifyPropertyChanged
{
private bool _isActive = false;
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Gets or sets the instance of <see cref="System.Windows.Controls.Page"/> that will be used to display in frame.
/// </summary>
public Object Instance { get; set; }
/// <summary>
/// Gets or sets the type of <see cref="System.Windows.Controls.Page"/> that will be used to create the instance.
/// </summary>
public Type Type { get; set; }
/// <summary>
/// Gets or sets the name of the item that will be displayed on the menu.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or sets an identifier by which the menu can be navigated with the help of <see cref="Controls.Navigation.Navigate(string, bool)"/>.
/// </summary>
public string Tag { get; set; }
/// <summary>
/// Gets or sets method that will be run when clicking.
/// </summary>
public Action Action { get; set; }
/// <summary>
/// Gets information whether an <see cref="NavItem"/> has subelements.
/// </summary>
public bool IsDropdown { get { return SubItems != null && SubItems.Length > 0; } }
/// <summary>
/// Gets or sets subelements for the <see cref="NavItem"/>. If it is established, the main instance is ignored.
/// </summary>
public NavItem[] SubItems { get; set; }
/// <summary>
/// Gets or sets the icon that will be displayed in the menu.
/// </summary>
public MiconIcon Icon { get; set; }
/// <summary>
/// Gets or sets the graphical icon that will be displayed in the menu.
/// </summary>
public BitmapSource Image { get; set; }
public string ImageUri
{
set
{
this.Image = new BitmapImage(new Uri(value));
}
}
/// <summary>
/// Gets the unicode character that corresponds to the selected icon.
/// </summary>
public char RawIcon => MiconGlyph.ToGlyph(Icon);
/// <summary>
/// Gets or sets whether the current item is active at the moment.
/// </summary>
public bool IsActive
{
get
{
return this._isActive;
}
set
{
if (value != this._isActive)
{
this._isActive = value;
this.OnPropertyChanged("IsActive");
}
}
}
protected void OnPropertyChanged(string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
}
using System;
using System.Diagnostics;
using System.Windows.Input;
namespace WPFUI.Common
{
/// <summary>
/// A command whose sole purpose is to
/// relay its functionality to other
/// objects by invoking delegates. The
/// default return value for the CanExecute
/// method is 'true'.
/// </summary>
public class RelayCommand : ICommand
{
#region Fields
readonly Action<object> _execute;
readonly Predicate<object> _canExecute;
#endregion // Fields
#region Constructors
/// <summary>
/// Creates a new command that can always execute.
/// </summary>
/// <param name="execute">The execution logic.</param>
public RelayCommand(Action<object> execute)
: this(execute, null)
{
}
/// <summary>
/// Creates a new command.
/// </summary>
/// <param name="execute">The execution logic.</param>
/// <param name="canExecute">The execution status logic.</param>
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
_execute = execute;
_canExecute = canExecute;
}
#endregion // Constructors
#region ICommand Members
[DebuggerStepThrough]
public bool CanExecute(object parameters)
{
return _canExecute == null ? true : _canExecute(parameters);
}
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void Execute(object parameters)
{
_execute(parameters);
}
#endregion // ICommand Members
}
}
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows;
namespace WPFUI.Controls
{
public class Button : System.Windows.Controls.Button
{
public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register("Glyph",
typeof(Common.MiconIcon), typeof(Button),
new PropertyMetadata(Common.MiconIcon.None, OnGlyphChanged));
public static readonly DependencyProperty RawGlyphProperty = DependencyProperty.Register("RawGlyph",
typeof(string), typeof(Button), new PropertyMetadata(""));
public static readonly DependencyProperty IsGlyphProperty = DependencyProperty.Register("IsGlyph",
typeof(bool), typeof(Button), new PropertyMetadata(false));
public bool IsGlyph
{
get => (bool) GetValue(IsGlyphProperty);
set => SetValue(IsGlyphProperty, value);
}
public Common.MiconIcon Glyph
{
get => (Common.MiconIcon) GetValue(GlyphProperty);
set => SetValue(GlyphProperty, value);
}
private static void OnGlyphChanged(DependencyObject dependency, DependencyPropertyChangedEventArgs eventArgs)
{
if (dependency is not Button control) return;
control.SetValue(IsGlyphProperty, true);
control.SetValue(RawGlyphProperty, Common.MiconGlyph.ToString(control.Glyph));
}
}
}
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System;
using System.Windows;
using System.Windows.Controls;
namespace WPFUI.Controls
{
public partial class CardAction : ContentControl
{
public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register("Glyph",
typeof(Common.MiconIcon), typeof(CardAction), new PropertyMetadata(Common.MiconIcon.None, OnGlyphChanged));
public static readonly DependencyProperty RawGlyphProperty = DependencyProperty.Register("RawGlyph",
typeof(string), typeof(CardAction), new PropertyMetadata(""));
public static readonly DependencyProperty IsGlyphProperty = DependencyProperty.Register("IsGlyph",
typeof(bool), typeof(CardAction), new PropertyMetadata(false));
public static readonly DependencyProperty BorderCommandProperty =
DependencyProperty.Register("BorderCommand", typeof(Common.RelayCommand), typeof(CardAction), new PropertyMetadata(null));
public Common.RelayCommand BorderCommand => (Common.RelayCommand) GetValue(BorderCommandProperty);
public Action Click { get; set; }
public bool IsGlyph
{
get => (bool) GetValue(IsGlyphProperty);
set => SetValue(IsGlyphProperty, value);
}
public Common.MiconIcon Glyph
{
get => (Common.MiconIcon) GetValue(GlyphProperty);
set => SetValue(GlyphProperty, value);
}
public CardAction()
{
Click = () => { };
SetValue(BorderCommandProperty, new Common.RelayCommand(o => Click()));
}
private static void OnGlyphChanged(DependencyObject dependency, DependencyPropertyChangedEventArgs eventArgs)
{
if (dependency is not CardAction control) return;
control.SetValue(IsGlyphProperty, true);
control.SetValue(RawGlyphProperty, Common.MiconGlyph.ToString(control.Glyph));
}
}
}
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows;
using System.Windows.Controls;
using WPFUI.Common;
namespace WPFUI.Controls
{
public partial class CardCollapse : ContentControl
{
public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title",
typeof(string), typeof(CardCollapse), new PropertyMetadata(""));
public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register("Glyph",
typeof(MiconIcon), typeof(CardCollapse), new PropertyMetadata(MiconIcon.None, OnGlyphChanged));
public static readonly DependencyProperty RawGlyphProperty = DependencyProperty.Register("RawGlyph",
typeof(string), typeof(CardCollapse), new PropertyMetadata(""));
public static readonly DependencyProperty IsContentVisibleProperty = DependencyProperty.Register("IsContentVisible",
typeof(bool), typeof(CardCollapse), new PropertyMetadata(false));
public static readonly DependencyProperty IsGlyphProperty = DependencyProperty.Register("IsGlyph",
typeof(bool), typeof(CardCollapse), new PropertyMetadata(false));
public static readonly DependencyProperty BorderCommandProperty =
DependencyProperty.Register("BorderCommand",
typeof(RelayCommand), typeof(CardCollapse), new PropertyMetadata(null));
public RelayCommand BorderCommand => (RelayCommand) GetValue(BorderCommandProperty);
public bool IsGlyph => (bool) GetValue(IsGlyphProperty);
public string Title
{
get => (string) GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
public bool IsContentVisible
{
get => (bool) GetValue(IsContentVisibleProperty);
set => SetValue(IsContentVisibleProperty, value);
}
public MiconIcon Glyph
{
get => (MiconIcon) GetValue(GlyphProperty);
set => SetValue(GlyphProperty, value);
}
public CardCollapse() => SetValue(BorderCommandProperty, new RelayCommand(o => CardOnClick()));
private void CardOnClick() => IsContentVisible = !IsContentVisible;
private static void OnGlyphChanged(DependencyObject dependency, DependencyPropertyChangedEventArgs eventArgs)
{
if (dependency is not CardCollapse control) return;
control.SetValue(IsGlyphProperty, true);
control.SetValue(RawGlyphProperty, MiconGlyph.ToString(control.Glyph));
}
}
}
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace WPFUI.Controls
{
public partial class CardProfile : ContentControl
{
public static readonly DependencyProperty SourceProperty = DependencyProperty.Register("Source",
typeof(BitmapSource), typeof(CardProfile), new PropertyMetadata(new BitmapImage()));
public BitmapSource Source
{
get => GetValue(SourceProperty) as BitmapSource;
set => SetValue(SourceProperty, value);
}
}
}
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
namespace WPFUI.Controls
{
public partial class CodeBlock : System.Windows.Controls.TextBlock
{
}
}
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System;
using System.Windows;
using static System.String;
namespace WPFUI.Controls
{
public partial class Hyperlink : Button
{
public static readonly DependencyProperty NavigateUriProperty = DependencyProperty.Register("NavigateUri",
typeof(string), typeof(Hyperlink), new PropertyMetadata(Empty));
public string NavigateUri
{
get => GetValue(NavigateUriProperty) as string;
set => SetValue(NavigateUriProperty, value);
}
public Hyperlink() => Click += RequestNavigate;
private void RequestNavigate(object sender, RoutedEventArgs eventArgs)
{
if (IsNullOrEmpty(NavigateUri)) return;
System.Diagnostics.ProcessStartInfo sInfo = new (new Uri(NavigateUri).AbsoluteUri)
{
UseShellExecute = true
};
System.Diagnostics.Process.Start(sInfo);
}
}
}
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows;
namespace WPFUI.Controls
{
public partial class Icon : System.Windows.Controls.Label
{
public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register("Glyph",
typeof(Common.MiconIcon), typeof(Icon), new PropertyMetadata(Common.MiconIcon.Accept, new PropertyChangedCallback(OnGlyphChanged)));
public static readonly DependencyProperty RawGlyphProperty = DependencyProperty.Register("RawGlyph",
typeof(string), typeof(Icon), new PropertyMetadata("\uEA01"));
public Common.MiconIcon Glyph
{
get => (Common.MiconIcon) GetValue(GlyphProperty);
set => SetValue(GlyphProperty, value);
}
private static void OnGlyphChanged(DependencyObject dependency, DependencyPropertyChangedEventArgs eventArgs)
{
if (dependency is not Icon control) return;
control.SetValue(RawGlyphProperty, Common.MiconGlyph.ToString(control.Glyph));
}
}
}
<UserControl
x:Class="WPFUI.Controls.Navigation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="clr-namespace:WPFUI.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<Grid Background="{DynamicResource WUNavBackground}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Button
Grid.Row="0"
HorizontalAlignment="Left"
Click="Button_Hamburger"
KeyboardNavigation.IsTabStop="False"
Style="{StaticResource WUNavHamburger}" />
<ScrollViewer
Grid.Row="1"
HorizontalScrollBarVisibility="Disabled"
Style="{StaticResource WUScrollViewer}"
VerticalScrollBarVisibility="Hidden">
<ItemsControl
x:Name="ItemsControlNavigation"
Width="{Binding MinBarWidth, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=1}, Mode=OneWay}"
ItemsSource="{Binding Items, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=1}, Mode=OneWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Tag="0">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="common:NavItem">
<DataTemplate.Resources>
<Storyboard x:Key="ExpandNavigation">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="button" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="2" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="button" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="2" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</DataTemplate.Resources>
<Button
HorizontalAlignment="Stretch"
Click="Button_NavItem"
Style="{StaticResource WUNavItemButton}"
Tag="{Binding Tag, Mode=OneTime}">
<StackPanel Margin="0,12" Orientation="Horizontal">
<Grid Width="{Binding MinBarWidth, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=1}, Mode=OneWay}" Height="18">
<TextBlock FontFamily="{DynamicResource Micon}" Text="{Binding RawIcon, Mode=OneTime}">
<TextBlock.Style>
<Style BasedOn="{StaticResource WUNavHamburgerIcon}" TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsActive, Mode=OneWay}" Value="True">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource WUForeground}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
<TextBlock Text="{Binding Name, Mode=OneTime}">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsActive, Mode=OneWay}" Value="True">
<Setter Property="Foreground" Value="{DynamicResource WUForeground}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<ItemsControl
x:Name="ItemsControlFooter"
Grid.Row="2"
Width="{Binding MinBarWidth, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=1}, Mode=OneWay}"
ItemsSource="{Binding Footer, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=1}, Mode=OneWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
Tag="0">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="common:NavItem">
<DataTemplate.Resources>
<Storyboard x:Key="ExpandNavigation">
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="button" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="2" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="button" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="2" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</DataTemplate.Resources>
<Button
HorizontalAlignment="Stretch"
Click="Button_NavItem"
Style="{StaticResource WUNavItemButton}"
Tag="{Binding Tag, Mode=OneTime}">
<StackPanel Margin="0,12" Orientation="Horizontal">
<Grid Width="{Binding MinBarWidth, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=1}, Mode=OneWay}" Height="18">
<TextBlock FontFamily="{StaticResource Micon}" Text="{Binding RawIcon, Mode=OneTime}">
<TextBlock.Style>
<Style BasedOn="{StaticResource WUNavHamburgerIcon}" TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsActive, Mode=OneWay}" Value="True">
<Setter Property="TextBlock.Foreground" Value="{DynamicResource WUForeground}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Grid>
<TextBlock Text="{Binding Name, Mode=OneTime}">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsActive, Mode=OneWay}" Value="True">
<Setter Property="Foreground" Value="{DynamicResource WUForeground}" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using WPFUI.Common;
namespace WPFUI.Controls
{
/// <summary>
/// Interaction logic for Navigation.xaml
/// </summary>
public partial class Navigation : UserControl
{
protected DoubleAnimation _navExpander;
protected Frame _rootFrame;
protected Action?
_onNavigate = null;
protected string
_currentPage = string.Empty,
_pagesFolder = string.Empty;
protected bool
_navExpanded = false,
_isLoading = false,
_licenseAccepted = false;
public static readonly DependencyProperty
ItemsProperty = DependencyProperty.Register("Items", typeof(ObservableCollection<NavItem>), typeof(Navigation), new PropertyMetadata(new ObservableCollection<NavItem>())),
FooterProperty = DependencyProperty.Register("Footer", typeof(ObservableCollection<NavItem>), typeof(Navigation), new PropertyMetadata(new ObservableCollection<NavItem>())),
MinBarWidthProperty = DependencyProperty.Register("MinBarWidth", typeof(int?), typeof(Navigation), new PropertyMetadata(44)),
MaxBarWidthProperty = DependencyProperty.Register("MaxBarWidth", typeof(int?), typeof(Navigation), new PropertyMetadata(220));
/// <summary>
/// Gets or sets the list of <see cref="NavItem"/> that will be displayed on the menu.
/// </summary>
public ObservableCollection<NavItem> Items
{
get => this.GetValue(ItemsProperty) as ObservableCollection<NavItem>;
set => this.SetValue(ItemsProperty, value);
}
/// <summary>
/// Gets or sets the list of <see cref="NavItem"/> which will be displayed at the bottom of the navigation and will not be scrolled.
/// </summary>
public ObservableCollection<NavItem> Footer
{
get => this.GetValue(FooterProperty) as ObservableCollection<NavItem>;
set => this.SetValue(FooterProperty, value);
}
/// <summary>
/// Gets or sets the action that will be triggered during navigation.
/// </summary>
public Action? OnNavigate
{
get => this._onNavigate;
set => this._onNavigate = value;
}
/// <summary>
/// Gets or sets the minimum width of the collapsed menu.
/// </summary>
public int MinBarWidth
{
get => (int)(this.GetValue(MinBarWidthProperty) as int?);
set => this.SetValue(MinBarWidthProperty, value);
}
/// <summary>
/// Gets or sets the maximum width of the expanded menu.
/// </summary>
public int MaxBarWidth
{
get => (int)(this.GetValue(MaxBarWidthProperty) as int?);
set => this.SetValue(MaxBarWidthProperty, value);
}
/// <summary>
/// Gets or sets absolute Namespace in the application files where the <see cref="System.Windows.Controls.Page"/> are located. <c>eg.: MyApp.Views.Pages</c>
/// </summary>
public string Catalog
{
get { return this._pagesFolder; }
set { this._pagesFolder = value; }
}
/// <summary>
/// Gets or sets the <see cref="System.Windows.Controls.Frame"/> in which the <see cref="System.Windows.Controls.Page"/> will be loaded after navigation.
/// </summary>
public Frame Frame
{
get { return this._rootFrame; }
set
{
this._rootFrame = value;
this._rootFrame.NavigationUIVisibility = NavigationUIVisibility.Hidden;
this._rootFrame.Navigating += FrameOnNavigating;
}
}
/// <summary>
/// Gets currently active <see cref="System.Windows.Controls.Page"/> tag.
/// </summary>
public string PageNow => this._currentPage;
public Navigation()
{
InitializeComponent();
}
public void InitializeNavigation(string navigate = "", string activepage = "")
{
if (this.Items == null)
return;
if (!String.IsNullOrEmpty(navigate))
this.Navigate(navigate, true);
if (!String.IsNullOrEmpty(activepage))
for (int i = 0; i < this.Items.Count; i++)
if (this.Items[i].Tag == activepage)
this.Items[i].IsActive = true;
}
/// <summary>
/// Loads a <see cref="System.Windows.Controls.Page"/> instance into <see cref="Navigation.Frame"/> based on the <see cref="NavItem.Tag"/>.
/// </summary>
public void Navigate(string pageTypeName, bool refresh = false)
{
if (this.Items == null || this.Items.Count == 0 || this._rootFrame == null)
return;
if (pageTypeName == this._currentPage)
return;
for (int i = 0; i < this.Items.Count; i++)
if (this.Items[i].Tag == pageTypeName)
{
Items[i].Action?.Invoke();
if (this.Items[i].Instance == null || refresh)
{
if (this.Items[i].Type != null)
{
this.Items[i].Instance = Activator.CreateInstance(this.Items[i].Type);
}
else if (this.Items[i].Type == null && !string.IsNullOrEmpty(this._pagesFolder))
{
//We assume that we will always enter the correct name
Type pageType = Type.GetType(this._pagesFolder + pageTypeName);
if (!refresh && this._rootFrame.Content != null && this._rootFrame.Content.GetType() == pageType)
return;
this.Items[i].Instance = Activator.CreateInstance(pageType);
}
else
{
//Brake!
return;
}
}
this._rootFrame.Navigate(this.Items[i].Instance);
this.Items[i].IsActive = true;
if (this.Items[i].Type != null && this.Items[i].Type.GetMethod("OnNavigationRequest") != null)
this.Items[i].Type.GetMethod("OnNavigationRequest").Invoke(this.Items[i].Instance, null);
}
else
{
this.Items[i].IsActive = false;
}
if (this.Footer != null && this.Footer.Count > 0)
{
for (int i = 0; i < this.Footer.Count; i++)
if (this.Footer[i].Tag == pageTypeName)
{
this.Footer[i].Action?.Invoke();
if (this.Footer[i].Instance == null || refresh)
{
if (this.Footer[i].Type != null)
{
this.Footer[i].Instance = Activator.CreateInstance(this.Footer[i].Type);
}
else if (this.Footer[i].Type == null && !string.IsNullOrEmpty(this._pagesFolder))
{
//We assume that we will always enter the correct name
Type pageType = Type.GetType(this._pagesFolder + pageTypeName);
if (!refresh && this._rootFrame.Content != null && this._rootFrame.Content.GetType() == pageType)
return;
this.Footer[i].Instance = Activator.CreateInstance(pageType);
}
else
{
//Brake!
return;
}
}
this._rootFrame.Navigate(this.Footer[i].Instance);
this.Footer[i].IsActive = true;
if (this.Footer[i].Type != null && this.Footer[i].Type.GetMethod("OnNavigationRequest") != null)
this.Footer[i].Type.GetMethod("OnNavigationRequest").Invoke(this.Footer[i].Instance, null);
}
else
{
this.Footer[i].IsActive = false;
}
}
this._currentPage = pageTypeName;
if (_onNavigate != null)
_onNavigate();
}
private void ToggleNavigation()
{
if (this._navExpander == null)
this._navExpander = new DoubleAnimation()
{
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseInOut },
Duration = TimeSpan.FromSeconds(0.4)
};
this._navExpander.From = ItemsControlNavigation.ActualWidth;
this._navExpander.To = this._navExpanded ? MinBarWidth : MaxBarWidth;
ItemsControlNavigation.BeginAnimation(ItemsControl.WidthProperty, this._navExpander);
if (this.Footer != null && this.Footer.Count > 0)
ItemsControlFooter.BeginAnimation(ItemsControl.WidthProperty, this._navExpander);
this._navExpanded = !this._navExpanded;
}
private void FrameOnNavigating(object sender, NavigatingCancelEventArgs e)
{
if (e.Content == null)
return;
this._rootFrame.NavigationService.RemoveBackEntry();
}
private void Button_Hamburger(object sender, RoutedEventArgs e)
{
this.ToggleNavigation();
}
private void Button_NavItem(object sender, RoutedEventArgs e)
{
this.Navigate((sender as System.Windows.Controls.Button).Tag.ToString());
}
}
}
<UserControl
x:Class="WPFUI.Controls.NavigationBubble"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="clr-namespace:WPFUI.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<ScrollViewer
HorizontalScrollBarVisibility="Disabled"
Style="{StaticResource WUScrollViewer}"
VerticalScrollBarVisibility="Hidden">
<Grid HorizontalAlignment="Left">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ItemsControl
Grid.Row="0"
ItemsSource="{Binding Items, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=1}, Mode=OneWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="common:NavItem">
<local:NavigationBubbleItem
Click="Button_NavItem"
Content="{Binding Name, Mode=OneTime}"
Glyph="{Binding Icon, Mode=OneTime}"
IsActive="{Binding Path=IsActive, Mode=OneWay}"
Tag="{Binding Tag, Mode=OneTime}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ItemsControl
Grid.Row="1"
ItemsSource="{Binding Footer, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=1}, Mode=OneWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="common:NavItem">
<local:NavigationBubbleItem
Click="Button_NavItem"
Content="{Binding Name, Mode=OneTime}"
Glyph="{Binding Icon, Mode=OneTime}"
IsActive="{Binding Path=IsActive, Mode=OneWay}"
Tag="{Binding Tag, Mode=OneTime}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</ScrollViewer>
</UserControl>
此差异已折叠。
// This Source Code Form is subject to the terms of the GNU General Public License, Version 3.
// If a copy of the GPL was not distributed with this file, You can obtain one at https://www.gnu.org/licenses/gpl-3.0.txt.
// Copyright (C) 2021 Leszek Pomianowski & WPF UI Contributors
// All Rights Reserved.
namespace WPFUI.Controls
{
class NavigationBubbleItem : NavigationItem
{
}
}
<UserControl
x:Class="WPFUI.Controls.NavigationFluent"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="clr-namespace:WPFUI.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<ScrollViewer
HorizontalScrollBarVisibility="Disabled"
Style="{StaticResource WUScrollViewer}"
VerticalScrollBarVisibility="Hidden">
<Grid Width="250" HorizontalAlignment="Left">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ItemsControl
Grid.Row="0"
Width="250"
ItemsSource="{Binding Items, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=1}, Mode=OneWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="common:NavItem">
<local:NavigationFluentItem
Click="Button_NavItem"
Content="{Binding Name, Mode=OneTime}"
Glyph="{Binding Icon, Mode=OneTime}"
Image="{Binding Image, Mode=OneTime}"
IsActive="{Binding Path=IsActive, Mode=OneWay}"
Tag="{Binding Tag, Mode=OneTime}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ItemsControl
Grid.Row="1"
ItemsSource="{Binding Footer, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=1}, Mode=OneWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="common:NavItem">
<local:NavigationFluentItem
Click="Button_NavItem"
Content="{Binding Name, Mode=OneTime}"
Glyph="{Binding Icon, Mode=OneTime}"
Image="{Binding Image, Mode=OneTime}"
IsActive="{Binding Path=IsActive, Mode=OneWay}"
Tag="{Binding Tag, Mode=OneTime}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</ScrollViewer>
</UserControl>
此差异已折叠。
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows;
using System.Windows.Media.Imaging;
namespace WPFUI.Controls
{
public partial class NavigationFluentItem : NavigationItem
{
public static readonly DependencyProperty ImageProperty = DependencyProperty.Register("Image",
typeof(BitmapSource), typeof(NavigationFluentItem), new PropertyMetadata(new BitmapImage(), OnImageChanged));
public static readonly DependencyProperty IsImageProperty = DependencyProperty.Register("IsImage",
typeof(bool), typeof(NavigationFluentItem), new PropertyMetadata(false));
public BitmapSource Image
{
get => GetValue(ImageProperty) as BitmapSource;
set => SetValue(ImageProperty, value);
}
public bool IsImage { get; set; }
private static void OnImageChanged(DependencyObject dependency, DependencyPropertyChangedEventArgs eventArgs)
{
if (dependency is not NavigationFluentItem control) return;
control.SetValue(IsImageProperty, true);
}
}
}
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
using System.Windows;
using WPFUI.Common;
namespace WPFUI.Controls
{
public partial class NavigationItem : System.Windows.Controls.Button
{
public static readonly DependencyProperty GlyphProperty = DependencyProperty.Register("Glyph",
typeof(MiconIcon), typeof(NavigationItem), new PropertyMetadata(MiconIcon.None, OnGlyphChanged));
public static readonly DependencyProperty RawGlyphProperty = DependencyProperty.Register("RawGlyph",
typeof(string), typeof(NavigationItem), new PropertyMetadata(""));
public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register("IsActive",
typeof(bool), typeof(NavigationItem), new PropertyMetadata(false));
public static readonly DependencyProperty IsGlyphProperty = DependencyProperty.Register("IsGlyph",
typeof(bool), typeof(NavigationItem), new PropertyMetadata(false));
public bool IsGlyph => (bool)this.GetValue(IsGlyphProperty);
public bool IsActive
{
get => (bool) GetValue(IsActiveProperty);
set => SetValue(IsActiveProperty, value);
}
public MiconIcon Glyph
{
get => (MiconIcon) GetValue(GlyphProperty);
set => SetValue(GlyphProperty, value);
}
private static void OnGlyphChanged(DependencyObject dependency, DependencyPropertyChangedEventArgs eventArgs)
{
if (dependency is not NavigationItem control) return;
control.SetValue(IsGlyphProperty, true);
control.SetValue(RawGlyphProperty, MiconGlyph.ToString(control.Glyph));
}
}
}
<UserControl x:Class="WPFUI.Controls.WindowNavigation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFUI.Controls"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Background="{DynamicResource WUBackground}"
MouseDown="DragWindow"
MouseLeftButtonDown="DragMaximize">
<StackPanel
x:Name="TitleBarNavigationStack"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Orientation="Horizontal">
<Button
x:Name="MinimizeButton"
Click="AppBarButton"
KeyboardNavigation.IsTabStop="False"
Style="{StaticResource WUWinNavButtonMinimize}"
Tag="minimize" />
<Button
x:Name="MaximizeButton"
Click="AppBarButton"
KeyboardNavigation.IsTabStop="False"
Style="{StaticResource WUWinNavButtonMaximize}"
Tag="maximize" />
<Button
Click="AppBarButton"
KeyboardNavigation.IsTabStop="False"
Style="{StaticResource WUWinNavButtonClose}"
Tag="close" />
</StackPanel>
</Grid>
</UserControl>
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- http://xtoolkit.github.io/Micon/icons/ -->
<FontFamily x:Key="FluentIcons">pack://application:,,,/WPFUI;component/Fonts/#FluentSystemIcons-Regular</FontFamily>
<FontFamily x:Key="Micon">pack://application:,,,/WPFUI;component/Fonts/#micon</FontFamily>
<FontFamily x:Key="FiraCode">pack://application:,,,/WPFUI;component/Fonts/#Fira Code</FontFamily>
</ResourceDictionary>
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册