Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
WPF: How to display content in an Expander
WhatsApp
Nipun Tomar
13y
35.9
k
0
0
25
Blog
The following XAML demonstrates how to use two
Expander
objects.The first
Expander
expands horizontally and uses an image in its header. The second
Expander
contains a set of
System.Windows.Controls.Button
objects and expands downward.
XAML CODE:
<
Window
x
:
Class
="Expander.MainWindow"
xmlns
=
http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns
:
x
=
http://schemas.microsoft.com/winfx/2006/xaml
Title
="MainWindow"
Height
="200"
Width
="300">
<
ScrollViewer
HorizontalScrollBarVisibility
="Auto"
VerticalScrollBarVisibility
="Auto">
<
StackPanel
HorizontalAlignment
="Left">
<
Expander
ExpandDirection
="Right"
IsExpanded
="True">
<
Expander.Header
>
<
Image
Source
="Apress.gif"/>
</
Expander.Header
>
<
TextBlock
TextWrapping
="Wrap"
MaxWidth
="200">
Windows Presentation Foundation (WPF) is the presentation
subsystem feature of the .NET Framework 4.0,that provide good
design and advance controls. Silverlight
i
s the Subset of
WPF.
Through WPF we can create Windows and WebBrowser Application.
</
TextBlock
>
</
Expander
>
<
Expander
Header
="Buttons">
<
StackPanel
>
<
StackPanel
Orientation
="Horizontal">
<
Button
Content
="Button 1"
Margin
="2"/>
<
Button
Content
="Button 2"
Margin
="2"/>
<
Button
Content
="Button 3"
Margin
="2"/>
<
Button
Content
="Button 4"
Margin
="2"/>
<
Button
Content
="Button 5"
Margin
="2"/>
</
StackPanel
>
<
StackPanel
HorizontalAlignment
="Left">
<
Button
Content
="Button A"
Margin
="2" />
<
Button
Content
="Button B"
Margin
="2" />
<
Button
Content
="Button C"
Margin
="2" />
<
Button
Content
="Button D"
Margin
="2" />
<
Button
Content
="Button E"
Margin
="2" />
</
StackPanel
>
</
StackPanel
>
</
Expander
>
</
StackPanel
>
</
ScrollViewer
>
</
Window
>
Up Next
WPF: Content Presenter
Ebook Download
View all
WPF Simplified: Build Windows Apps Using C# and XAML
Read by 1.5k people
Download Now!
Learn
View all
Membership not found