Window with Menu, ToolBar, StatusBar
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WpfApplication1" Height="400" Width="500"
WindowStartupLocation ="CenterScreen" >
<DockPanel>
<Menu DockPanel.Dock ="Top" HorizontalAlignment="Left" Background="White" BorderBrush ="Black">
<MenuItem Header="_File" Click ="FileExit_Click" >
<Separator/>
<MenuItem Header ="_Exit" MouseEnter ="MouseEnterExitArea" MouseLeave ="MouseLeaveArea" Click ="FileExit_Click"/>
</MenuItem>
<MenuItem Header="_Edit">
<MenuItem Command ="ApplicationCommands.Copy"/>
<MenuItem Command ="ApplicationCommands.Cut"/>
<MenuItem Command ="ApplicationCommands.Paste"/>
</MenuItem>
<MenuItem Header="_Tools">
<MenuItem Header ="_Spelling Hints" MouseEnter ="MouseEnterToolsHintsArea" MouseLeave ="MouseLeaveArea" Click ="ToolsSpellingHints_Click"/>
</MenuItem>
</Menu>
<ToolBar DockPanel.Dock ="Top" >
<Button Content ="Exit" MouseEnter ="MouseEnterExitArea"
MouseLeave ="MouseLeaveArea" Click ="FileExit_Click"/>
<Separator/>
<Button Content ="Check" MouseEnter ="MouseEnterToolsHintsArea"
MouseLeave ="MouseLeaveArea" Click ="ToolsSpellingHints_Click"
Cursor="Help" />
</ToolBar>
<StatusBar DockPanel.Dock ="Bottom" Background="Beige" >
<StatusBarItem>
<TextBlock Name="statBarText">Ready</TextBlock>
</StatusBarItem>
</StatusBar>
<Grid DockPanel.Dock ="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<GridSplitter Grid.Column ="0" Width ="5" Background ="Gray" />
<StackPanel Grid.Column="0" VerticalAlignment ="Stretch" >
<Label Name="lblSpellingInstructions" Margin="10,10,0,0">Spelling Hints</Label>
<Expander Name="expanderSpelling" Header ="Try these!" Margin="10,10,10,10">
<Label Name ="lblSpellingHints"/>
</Expander>
</StackPanel>
<TextBox Grid.Column ="1"
SpellCheck.IsEnabled ="True"
AcceptsReturn ="True"
Name ="txtData">
</TextBox>
</Grid>
</DockPanel>
</Window>
//File:Window.xaml.vb
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Shapes
Namespace WpfApplication1
Public Partial Class MainWindow
Inherits System.Windows.Window
Public Sub New()
InitializeComponent()
SetF1CommandBinding()
End Sub
Protected Sub FileExit_Click(sender As Object, args As RoutedEventArgs)
Application.Current.Shutdown()
End Sub
Protected Sub ToolsSpellingHints_Click(sender As Object, args As RoutedEventArgs)
Dim spellingHints As String = String.Empty
Dim [error] As SpellingError = txtData.GetSpellingError(txtData.CaretIndex)
If [error] IsNot Nothing Then
For Each s As String In [error].Suggestions
spellingHints += String.Format("{0}" & vbLf, s)
Next
lblSpellingHints.Content = spellingHints
expanderSpelling.IsExpanded = True
End If
End Sub
Protected Sub MouseEnterExitArea(sender As Object, args As RoutedEventArgs)
statBarText.Text = "Exit the Application"
End Sub
Protected Sub MouseEnterToolsHintsArea(sender As Object, args As RoutedEventArgs)
statBarText.Text = "Spelling Suggestions"
End Sub
Protected Sub MouseLeaveArea(sender As Object, args As RoutedEventArgs)
statBarText.Text = "Ready"
End Sub
Private Sub SetF1CommandBinding()
Dim helpBinding As New CommandBinding(ApplicationCommands.Help)
AddHandler helpBinding.CanExecute, AddressOf CanHelpExecute
AddHandler helpBinding.Executed, AddressOf HelpExecuted
CommandBindings.Add(helpBinding)
End Sub
Private Sub CanHelpExecute(sender As Object, e As CanExecuteRoutedEventArgs)
e.CanExecute = True
End Sub
Private Sub HelpExecuted(sender As Object, e As ExecutedRoutedEventArgs)
MessageBox.Show("type something!", "Help!")
End Sub
End Class
End Namespace
Related examples in the same category