WPF 应用程序 .Core 3.0 和 Microsoft Ribbon 控件库 4.0
WPF apps .Core 3.0 and microsoft ribbon control library 4.0
您好,我尝试使用 WPF、.Netcore 3.0 和 Microsoft ribbon control library 4.0 构建应用程序,但失败了。
我需要帮助或网络上的示例。
我确实在 GitHub 上查看了 Microsoft WPF-Sample,但没有找到适用于 .netcore 3.0
的色带示例
MainWindow.Xaml
<Window x:Class="WpfDoNetcore3.MainWindow"
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:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
xmlns:local="clr-namespace:WpfDoNetcore3"
mc:Ignorable="d"
x:Name="RibbonWindow"
Title="MainWindow" Height="450" Width="800">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ribbon:Ribbon x:Name="Ribbon" Title="Ribbon Title">
<ribbon:Ribbon.HelpPaneContent>
<ribbon:RibbonButton SmallImageSource="Images\Smallicon.png" />
</ribbon:Ribbon.HelpPaneContent>
<ribbon:Ribbon.QuickAccessToolBar>
<ribbon:RibbonQuickAccessToolBar >
<ribbon:RibbonButton x:Name="QATButton1"
SmallImageSource="Images\Smallicon.png" />
<ribbon:RibbonButton x:Name="QATButton2"
SmallImageSource="Images\Smallicon.png" />
</ribbon:RibbonQuickAccessToolBar>
</ribbon:Ribbon.QuickAccessToolBar>
<ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonApplicationMenu SmallImageSource="Images\Smallicon.png">
<ribbon:RibbonApplicationMenuItem Header="Hello _Ribbon"
x:Name="MenuItem1"
ImageSource="Images\Largeicon.png"/>
</ribbon:RibbonApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonTab x:Name="HomeTab"
Header="Home">
<ribbon:RibbonGroup x:Name="Group1"
Header="Group1">
<ribbon:RibbonButton x:Name="Button1"
LargeImageSource="Images\Largeicon.png"
Label="Button1" />
<ribbon:RibbonButton x:Name="Button2"
SmallImageSource="Images\Smallicon.png"
Label="Button2" />
<ribbon:RibbonButton x:Name="Button3"
SmallImageSource="Images\Smallicon.png"
Label="Button3" />
<ribbon:RibbonButton x:Name="Button4"
SmallImageSource="Images\Smallicon.png"
Label="Button4" />
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
</ribbon:Ribbon>
</Grid>
</Window>
Mainwindow.cs
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;
using System.Windows.Controls.Ribbon;
namespace WpfDoNetcore3
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
只需从 XAML 中删除 xmlns:ribbon
名称空间声明和 ribbon:
前缀并尝试构建:
<Window x:Class="WpfDoNetcore3.MainWindow"
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"
mc:Ignorable="d"
x:Name="RibbonWindow"
Title="MainWindow" Height="450" Width="800">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Ribbon x:Name="Ribbon" Title="Ribbon Title">
<Ribbon.HelpPaneContent>
<RibbonButton SmallImageSource="Images\Smallicon.png" />
</Ribbon.HelpPaneContent>
<Ribbon.QuickAccessToolBar>
<RibbonQuickAccessToolBar >
<RibbonButton x:Name="QATButton1"
SmallImageSource="Images\Smallicon.png" />
<RibbonButton x:Name="QATButton2"
SmallImageSource="Images\Smallicon.png" />
</RibbonQuickAccessToolBar>
</Ribbon.QuickAccessToolBar>
<Ribbon.ApplicationMenu>
<RibbonApplicationMenu SmallImageSource="Images\Smallicon.png">
<RibbonApplicationMenuItem Header="Hello _Ribbon"
x:Name="MenuItem1"
ImageSource="Images\Largeicon.png"/>
</RibbonApplicationMenu>
</Ribbon.ApplicationMenu>
<RibbonTab x:Name="HomeTab"
Header="Home">
<RibbonGroup x:Name="Group1"
Header="Group1">
<RibbonButton x:Name="Button1"
LargeImageSource="Images\Largeicon.png"
Label="Button1" />
<RibbonButton x:Name="Button2"
SmallImageSource="Images\Smallicon.png"
Label="Button2" />
<RibbonButton x:Name="Button3"
SmallImageSource="Images\Smallicon.png"
Label="Button3" />
<RibbonButton x:Name="Button4"
SmallImageSource="Images\Smallicon.png"
Label="Button4" />
</RibbonGroup>
</RibbonTab>
</Ribbon>
</Grid>
</Window>
这应该有效。 Ribbon
控件自 .NET Framework 4.5 以来一直是 WPF 本身的一部分,因此如果您以 Framework 4.5+ 或 .NET Core 3+ 为目标,则不必引用和使用任何外部库。
您好,我尝试使用 WPF、.Netcore 3.0 和 Microsoft ribbon control library 4.0 构建应用程序,但失败了。
我需要帮助或网络上的示例。 我确实在 GitHub 上查看了 Microsoft WPF-Sample,但没有找到适用于 .netcore 3.0
的色带示例MainWindow.Xaml
<Window x:Class="WpfDoNetcore3.MainWindow"
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:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
xmlns:local="clr-namespace:WpfDoNetcore3"
mc:Ignorable="d"
x:Name="RibbonWindow"
Title="MainWindow" Height="450" Width="800">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ribbon:Ribbon x:Name="Ribbon" Title="Ribbon Title">
<ribbon:Ribbon.HelpPaneContent>
<ribbon:RibbonButton SmallImageSource="Images\Smallicon.png" />
</ribbon:Ribbon.HelpPaneContent>
<ribbon:Ribbon.QuickAccessToolBar>
<ribbon:RibbonQuickAccessToolBar >
<ribbon:RibbonButton x:Name="QATButton1"
SmallImageSource="Images\Smallicon.png" />
<ribbon:RibbonButton x:Name="QATButton2"
SmallImageSource="Images\Smallicon.png" />
</ribbon:RibbonQuickAccessToolBar>
</ribbon:Ribbon.QuickAccessToolBar>
<ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonApplicationMenu SmallImageSource="Images\Smallicon.png">
<ribbon:RibbonApplicationMenuItem Header="Hello _Ribbon"
x:Name="MenuItem1"
ImageSource="Images\Largeicon.png"/>
</ribbon:RibbonApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonTab x:Name="HomeTab"
Header="Home">
<ribbon:RibbonGroup x:Name="Group1"
Header="Group1">
<ribbon:RibbonButton x:Name="Button1"
LargeImageSource="Images\Largeicon.png"
Label="Button1" />
<ribbon:RibbonButton x:Name="Button2"
SmallImageSource="Images\Smallicon.png"
Label="Button2" />
<ribbon:RibbonButton x:Name="Button3"
SmallImageSource="Images\Smallicon.png"
Label="Button3" />
<ribbon:RibbonButton x:Name="Button4"
SmallImageSource="Images\Smallicon.png"
Label="Button4" />
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
</ribbon:Ribbon>
</Grid>
</Window>
Mainwindow.cs
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;
using System.Windows.Controls.Ribbon;
namespace WpfDoNetcore3
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
只需从 XAML 中删除 xmlns:ribbon
名称空间声明和 ribbon:
前缀并尝试构建:
<Window x:Class="WpfDoNetcore3.MainWindow"
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"
mc:Ignorable="d"
x:Name="RibbonWindow"
Title="MainWindow" Height="450" Width="800">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Ribbon x:Name="Ribbon" Title="Ribbon Title">
<Ribbon.HelpPaneContent>
<RibbonButton SmallImageSource="Images\Smallicon.png" />
</Ribbon.HelpPaneContent>
<Ribbon.QuickAccessToolBar>
<RibbonQuickAccessToolBar >
<RibbonButton x:Name="QATButton1"
SmallImageSource="Images\Smallicon.png" />
<RibbonButton x:Name="QATButton2"
SmallImageSource="Images\Smallicon.png" />
</RibbonQuickAccessToolBar>
</Ribbon.QuickAccessToolBar>
<Ribbon.ApplicationMenu>
<RibbonApplicationMenu SmallImageSource="Images\Smallicon.png">
<RibbonApplicationMenuItem Header="Hello _Ribbon"
x:Name="MenuItem1"
ImageSource="Images\Largeicon.png"/>
</RibbonApplicationMenu>
</Ribbon.ApplicationMenu>
<RibbonTab x:Name="HomeTab"
Header="Home">
<RibbonGroup x:Name="Group1"
Header="Group1">
<RibbonButton x:Name="Button1"
LargeImageSource="Images\Largeicon.png"
Label="Button1" />
<RibbonButton x:Name="Button2"
SmallImageSource="Images\Smallicon.png"
Label="Button2" />
<RibbonButton x:Name="Button3"
SmallImageSource="Images\Smallicon.png"
Label="Button3" />
<RibbonButton x:Name="Button4"
SmallImageSource="Images\Smallicon.png"
Label="Button4" />
</RibbonGroup>
</RibbonTab>
</Ribbon>
</Grid>
</Window>
这应该有效。 Ribbon
控件自 .NET Framework 4.5 以来一直是 WPF 本身的一部分,因此如果您以 Framework 4.5+ 或 .NET Core 3+ 为目标,则不必引用和使用任何外部库。