Introduction:
Last Four days, we talked about WPF Introduction, AccessText Control, Board and Canvas, Calendar, CheckBox, ComboBox and ContextMenu Control. Today we will discuss about Datagrid, DatePicker, DockPanel, and DocumentViewer Control.
· Datagrid Control:
Represents a control that displays data in a customizable grid.
It starts from .Net Framework 4.0.
Please refer this: http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid%28v=vs.100%29.aspx
· DatePicker Control:
Represents a control that allows the user to select a date.
It starts from .Net Framework 4.0.
Please refer this: http://msdn.microsoft.com/en-us/library/system.windows.controls.datepicker.aspx
· DockPanel Control :
Defines an area where you can arrange child elements either horizontally or vertically, relative to each other.
Create ContextMenu in XAML:
<DockPanel Background="AliceBlue">
<TextBox Name="textBox1" TextWrapping="Wrap" Margin="10, 10, 5, 5" Grid.Row="7" Height="36" Width="202">The quick brown fox jumps over the lazy dog.
<TextBox.ContextMenu>
<ContextMenu>
<MenuItem Header="_USA" />
<Separator />
<MenuItem Header="_INDIA" />
<Separator />
<MenuItem Header="CHINA"/>
<Separator />
<MenuItem Header="SOUTH AFRICA" />
</ContextMenu>
</TextBox.ContextMenu>
</TextBox>
</DockPanel>
Create ContextMenu in Coding:
CheckBoxchkYes;
CheckBoxchkNo;
DockPaneldockPanel;
private voiddockPanelControl()
{
dockPanel = new DockPanel();
dockPanel.Background = Brushes.LightSlateGray;
dockPanel.Margin = new Thickness(10, 15, 5, 10);
dockPanel.Height = 100;
dockPanel.Width= 200;
dockControl(dockPanel);
this.Content = dockPanel;
}
privatevoid dockControl(DockPaneldpnl)
{
chkYes = newCheckBox();
chkYes.ClickMode = ClickMode.Press;
chkYes.Content = "Yes";
chkYes.IsChecked = true;
chkYes.Margin = new Thickness(10, 10, 25, 20);
chkNo = newCheckBox();
chkNo.ClickMode = ClickMode.Press;
chkNo.Content = "No";
chkNo.Margin = new Thickness(10, 10, 25, 20);
dpnl.Children.Add(chkYes);
dpnl.Children.Add(chkNo);
}
private voidWindow_Loaded(object sender, RoutedEventArgs e)
{
dockPanelControl();
}
· DocumentViewer Control:
Document viewing control that can host paginated FixedDocumentcontent such as an XpsDocument. Simple says that user can view all documents like (PDF, text. Image files)
FixedDocument:
It is a fixed format document with read Access for user.
Provides a Packagethat holds the content of an XPS document.
Package:
Container that can store multiple data objects.
Create ContextMenu in XAML:
<DocumentViewer Margin="20,12,12,26" Name="documentViewer1"Background="Azure" />
Create ContextMenu in Coding:
DocumentViewerdocViewer;
privatevoid documentViewerControl()
{
docViewer = new DocumentViewer();
docViewer.Background = Brushes.LightSlateGray;
this.Content = docViewer;
}
privatevoid Window_Loaded(objectsender, RoutedEventArgs e)
{
documentViewerControl();
}
Conclusion:
I hope, you to get some ideas about Datagrid, DatePicker, DockPanel, and DocumentViewer Control in WPF. Thanks for reading this article. We will talk about other controls in next Chapters.
No comments:
Post a Comment