Here We are going to create WPF Menu.
Open New Project:-

Now you will get like this:

Now Open File MainWindow.xaml(XAML File-Source):-
And Type Below Code in Your Editor
Open New Project:-

Now you will get like this:

Now Open File MainWindow.xaml(XAML File-Source):-
And Type Below Code in Your Editor
<Window x:Class="WpfApplicationMenu.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
Height="614" Width="829">
<Window.CommandBindings>
<CommandBinding Command="New" CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed"></CommandBinding>
</Window.CommandBindings>
<Grid>
<DockPanel>
<Menu DockPanel.Dock="Top" Margin="0,0,0,546">
<MenuItem Header="_File">
<MenuItem Command="New"/>
<Separator/>
<MenuItem Command="Save" Header="_Save"/>
<MenuItem Command="SaveAs"/>
<MenuItem Command="BrowseBack"/>
<MenuItem Header="_Exit"/>
</MenuItem>
<MenuItem Header="_Edit">
<MenuItem Command="Cut"/>
<MenuItem Command="Copy"/>
<MenuItem Command="Paste"/>
<MenuItem Command="Delete"/>
</MenuItem>
<MenuItem Header="_View">
</MenuItem>
<MenuItem Header="_Help"></MenuItem>
</Menu>
</DockPanel>
<TextBox AcceptsReturn="True" Name="txtEditor" Margin="0,25,0,0"></TextBox>
</Grid>
</Window>
You Will Get Design Like This:
Now Open Mainwindow.xml.cs and Type Below Code:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 WpfApplicationMenu
{
/// <summary>
/// Interaction logic for
MainWindow.xaml
/// </summary>
public partial class MainWindow :
Window
{
public MainWindow()
{
InitializeComponent();
}
private void
CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
private void
CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
txtEditor.Text = "";
}
}
}
Now Run the MainWindow.xaml:-
I hope This Program will help You .If You have any Query Then type.I will try to solve Your Query.
-Ravikumhar
:-#
ReplyDelete[-(
ReplyDelete