基窗体写好,后面已经很简单了
XAML代码
<local:BaseWindow x:Class="FYJ.Winui.MainWindow"
x:Name="mainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FYJ.Winui"
Title="MainWindow" Style="{StaticResource BaseWindowStyle}" ResizeMode="CanResize" IsShowMenuButton="true" IsShowSkinButton="true" Width="600" Height="300" Icon="pig.ico" >
<local:BaseWindow.ContextMenu>
<ContextMenu>
<MenuItem Header="File">
<MenuItem.Icon>
<Image Source="Resources/32x32/Add.png"></Image>
</MenuItem.Icon>
<MenuItem Header="xxxxx"></MenuItem>
</MenuItem>
<MenuItem Header="对方的快速反击的看法">
</MenuItem>
<MenuItem Header="大家撒谎的撒旦">
</MenuItem>
</ContextMenu>
</local:BaseWindow.ContextMenu>
<Grid/>
</local:BaseWindow>
至于后台代码 可以没有了
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Forms; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace FYJ.Winui { /// /// MainWindow.xaml 的交互逻辑 /// public partial class MainWindow : BaseWindow { public MainWindow() { InitializeComponent(); } } }