Changing the XamDataPresenter's View at Runtime

The XamDataPresenter is a look-less control and has the ability to display multiple views. The two views that it currently ships with are a GridView and a CarouselView. Essentially, with the underlying model that provides things such as hierarchical databinding, Outlook Group-By, AddNew, etc. a developer could use that framework to create their own view of their data. For instance, a cardview could be created to demonstrate another look for a given series of data.

To toggle between different views, simply set the view property to the view that you wish to have displayed:

private Infragistics.Windows.DataPresenter.GridView xamGridView;
private Infragistics.Windows.DataPresenter.CarouselView xamCarouselView;

private void Window_Loaded(object sender, RoutedEventArgs e)
{
   xamGridView = new Infragistics.Windows.DataPresenter.GridView();
   xamCarouselView = new Infragistics.Windows.DataPresenter.CarouselView();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
  if (this.xamDPViewSample.View.ToString() == xamGridView.ToString())
    this.xamDPViewSample.View = xamCarouselView;
  else if(this.xamDPViewSample.View.ToString() == xamCarouselView.ToString())
    this.xamDPViewSample.View = xamGridView;
}

Add a Comment

Be the first one to add a comment. Please Login or Register to add comment.