Free Study Guide for the Windows Presentation Framework exam 70-511: Items Control
- For this blog entry, I did a bunch of links, scroll down to see the code and short video
- If you are using a Windows Phone, there is an app that you can download to view the YouTube videos
A current example on MSDN, it’s a beauty!
- https://msdn.microsoft.com/en-us/library/ms752299.aspx
- How to do a XAML project with Visual Studio 2010
Using the Item Controls:
ListBox Control Information:
- ListControl Class:
- Represents a control that can be used to present a collection of items.
- https://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.aspx
- Item controls that are commonly used
- ListBox control information:
- Contains a list of selectable items.
- https://msdn.microsoft.com/en-us/library/system.windows.controls.listbox(VS.100).aspx
- ComboBox
- Represents a selection control with a drop-down list that can be shown or hidden by clicking the arrow on the control.
- https://msdn.microsoft.com/en-us/library/system.windows.controls.combobox.aspx
- Menu
- Represents a Windows menu control that enables you to hierarchically organize elements associated with commands and event handlers.
- https://msdn.microsoft.com/en-us/library/system.windows.controls.menu.aspx
- StatusBarStrip
- Represents a Windows status bar control.
- https://msdn.microsoft.com/en-us/library/system.windows.forms.statusstrip.aspx
- StatusBar
- Represents a Windows status bar control.
- Consider using the ToolStripStatusLabel replaces and adds functionality to the StatusBar control of previous versions, StatusBar is retained for both backward compatibility and future use if you choose
- https://msdn.microsoft.com/en-us/library/system.windows.forms.statusbar.aspx
- ToolStripStatusLabel
- Represents a panel in a StatusStrip control
- https://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripstatuslabel.aspx
- TabControl
- Represents a control that contains multiple items that share the same space on the screen.
- https://msdn.microsoft.com/en-us/library/system.windows.controls.tabcontrol.aspx
- ToolBar
- Provides a container for a group of commands or controls.
- https://msdn.microsoft.com/en-us/library/system.windows.controls.toolbar.aspx
- TreeView
- Represents a control that displays hierarchical data in a tree structure that has items that can expand and collapse.
- https://msdn.microsoft.com/en-us/library/system.windows.controls.treeview.aspx
- ListBox control information:
XAML CODE (Sample code is attached to article)
<Window x:Class="AttachedEvent.MainWindow"
xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="322" Width="534">
<Grid>
<TextBox Name="tb" Margin="42,215,12,12"
FontSize="28"
BorderThickness="5"
BorderBrush="Black">
Select
</TextBox>
<ListBox Name="lb"
Width="100"
SelectionChanged="ShowSelection"
SelectionMode="Single"
FontSize="28"
Margin="38,27,365,124"
BorderThickness="5"
BorderBrush="Black">
<ListBoxItem>Boom</ListBoxItem>
<ListBoxItem>Room</ListBoxItem>
<ListBoxItem>Moon</ListBoxItem>
</ListBox>
<ListBox Name="lb2" Width="100" SelectionChanged="ShowSelection"
SelectionMode="Single"
Margin="163,28,249,124"
FontSize="28"
BorderThickness="5"
BorderBrush="Red">
<ListBoxItem>Birds</ListBoxItem>
<ListBoxItem>Cat</ListBoxItem>
<ListBoxItem>Dog</ListBoxItem>
</ListBox>
</Grid>
</Window>
Code behind (Sample code is attached to article)
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 AttachedEvent
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void ShowSelection(object sender, SelectionChangedEventArgs e)
{
ListBoxItem lbi =
((sender as ListBox).SelectedItem
as ListBoxItem);
tb.Text =
" You selected " +
lbi.Content.ToString() + ".";
}