Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

WPF Wonders: An Alphabetical Compendium of WPF Controls : Page 3

Among many other changes, WPF brings a completely new set of controls. Learn which controls do what and pick up a few tips on getting the most out of them in your WPF applications.


advertisement

Ellipse

The Ellipse control draws a simple ellipse. The control's Fill and Stroke properties determine its interior and edge colors. Other stroke properties, such as StrokeDashArray and StrokeDashCap, control the edge's appearance.

The following code shows how ControlSamples draws its ellipse (see Figure 2).

<Ellipse Width="75" Height="30" Fill="White" Stroke="Red" StrokeThickness="3" StrokeDashArray="4,2"/>

Expander

The Expander control displays an arrow button that users can click to expand or hide the control's single child. Its IsExpanded property determines whether the control is currently expanded. The Header property determines what (if anything) the control displays next to its button.

Here's how ControlSamples creates its Expander. In this example, the Expander contains a Border that holds a StackPanel containing several Labels.

<Expander Margin="0,5,0,0" Width="150" Height="110" Header="Information" IsExpanded="True"> <Border Margin="2" BorderBrush="Orange" BorderThickness="3" CornerRadius="5"> <StackPanel> <Label Content="First Name: Rod"/> <Label Content="Last Name: Stephens"/> <Label Content="Occupation: Dilettante"/> </StackPanel> </Border> </Expander>

FlowDocument Viewers

Unlike the fixed document displayed by the DocumentViewer, a flow document's contents can flow as the available space changes, in much the same way that a web browser reflows a page of HTML when the browser resizes.

Like the fixed document, the flow document's structure is too complex to cover here, but basically, a FlowDocument contains Paragraph, Table, BlockUIContainer, and other objects that hold the document's content.

WPF includes three controls for viewing flow documents in different ways:

 
Figure 4. Preferred Pageviews: The FlowDocumentReader displays flow documents in page, scroll, or two-page mode.
  • The FlowDocumentPageViewer displays the document in page mode as a series of single pages that fit the viewer's current size.
  • The FlowDocumentScrollViewer displays the document as a single scrollable page like a web page.
  • The FlowDocumentReader can display the document in page mode, scroll mode, or a side-by-side two-page mode.
Figure 4 shows a FlowDocumentReader displaying a document in two-page mode. The buttons on the bottom right of center let you change the control's viewing mode.

Download the UseFlowDocumentReader example program and experiment with it to get a better idea of the control's display modes.

Frame

Most Windows developers think of Frame controls as a sort of group box with a header and a border. However, the WPF Frame control is a navigation control. It displays content and provides browser-like navigation tools that let you move forward and backward through an internally-maintained navigation history.

You can set the control's Source property to a URL that you want it to display. At run time, your program can use the control's Navigate method to go to a new URL. For example, the following C# code makes the Frame control named frmVbHelper open the web page http://www.vb-helper.com.

 
Figure 5. Nifty Navigation: The Frame control displays content such as web pages and provides browser-like navigation.



fraVbHelper.Navigate(New Uri("http://www.vb-helper.com"));

The control also provides methods that let you control the navigation from code. For example, the GoBack and GoForward methods move forward and backward through the navigation history.

Author's Note: If a user navigates to a new page by clicking a link on a web page, the Frame does not add the new page to its navigation history.

Figure 5 shows the UseFrame program example displaying a web page. The buttons along the top call the Frame's Navigate method to display new web pages. Below those buttons, you can see the navigation arrow buttons provided by the Frame control.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap