Changing the Visible Fields

Glossary Item Box

Infragistics(R) NetAdvantage(R) for WPF

Changing the Visible Fields

You can set xamDataPresenter™ Grid View's Field's Visibility property to determine whether that Field is shown. In Microsoft® Windows® Presentation Foundation, the Visibility property is an enumeration with three values:

The following procedure assumes you have a data bound xamDataPresenter, and you want to hide and collapse some of the Fields. For more information, see Creating xamDataPresenter in XAML.

  1. The following XAML creates an instance of XamDataPresenter and names it. The XAML then specifies the FieldLayouts object for xamDataPresenter, which contains the FieldLayout, which houses the FieldCollection. Then specify each Field, and on the 'ProductName' Field, set its Visibility to Collapsed, and on the Quantity, set its Visibility to Hidden.
    Note: Changes to the field layout are View independent, and therefore the code below will work with either GridView or CarouselView.

    In XAML:

    <igDP:XamDataPresenter x:Name="XamDataPresenter1" 
      ...
      >
    	<igDP:XamDataPresenter.FieldLayouts>
    		<igDP:FieldLayout>
    			<igDP:FieldLayout.Fields>
    				<igDP:Field Name="ProductName" Visibility="Collapsed" />
    				<igDP:Field Name="CostPerUnit" />
    				<igDP:Field Name="Quantity" Visibility="Hidden"/>
    				<igDP:Field Name="Discount" />
    				<igDP:Field Name="ShipAndHandle" />
    			</igDP:FieldLayout.Fields>
    		</igDP:FieldLayout>
    	</igDP:XamDataPresenter.FieldLayouts>
    </igDP:XamDataPresenter>
    

  2. Build and run the project. You should see something similar to the following. Where the ProductName Field is completely removed, the end user would have no knowledge of that Field. Whereas the 'Quantity' Field has left its space for where that Field would be at, if it was shown.

E-mail your feedback on this topic.

Opinion about our help? Take our survey.

Copyright © 2003-2007 Infragistics, Inc. All rights reserved.

Build Version: 7.1.20071.1320