none
PivotViewer Add Custom View

    General discussion

  • I want to remove the tiles and replace them with a DataGrid or a Bing map.

    Please don't point me to Roger Noble's site. It has no explanation about how he did this. But, an example of what he did is here:

    http://pivot.lobsterpot.com.au/flickr

    Click on the buttons in the top right to toggle between views.

    Tuesday, January 10, 2012 1:16 AM

All replies

  • The section "Locating the UI Elements" here: http://xpert360.wordpress.com/category/pivotviewer/ says that you can get at the objects inside the pivot viewer in order to make a custom view. However, I can't make sense of the code posted there. It doesn't work in the latest version of Silverlight 5 anyway.

    Tuesday, January 10, 2012 6:30 PM
  • Hi, the code posted on the blog is for PV V1 that shipped seperately for SL4. The SL5 PV control is very different and you cannot run any SL4 DLL's in a SL5 built app.

    Wednesday, January 11, 2012 2:46 AM
  • OK. But, I'm not working with any SL4 dlls. Do you know if there is a way to achieve the same result in SL5?

    Wednesday, January 11, 2012 4:00 AM
  • With SL5 PV you can get under the covers and I have been looking at replicating all the types of customisations that we achieved with the V1 control. For certain, more areas of the PV control are private, sealed or readonly. I almost finished the work last weekend and the add a custom view and custom buttons are the last items to complete a POC for. The collection of toolbar buttons is readonly whereas before we could add a button... that is where I got to on Sunday. Hide/show panels etc... are possible, a lot of styling is now built-in. Sadly, localization seems to have been missed!

    I am hopeful that we can do custom views and buttons but they may have to be implemented in a different way.

    Wednesday, January 11, 2012 4:31 AM
  • It's not easy and requires a good understanding of Silverlight/.NET but for a start...

    I have finished investigating now and this screen capture shows two cyan-coloured UIElements (Border's) added to the PivotViewer visual tree. This is my rough-and-ready sample code after poking around. Any custom view probably will bind to the selected items in the collection...

     

    Custom SL5 PivotViewer

    Accessing the PV V2 internals is almost identical to the old code posted for customising PV V1.

                CollectionViewerView cvv = ((CollectionViewerView)MyPV.PartContainer.Children[2]);
                Grid container = cvv.Content as Grid;
    
                Grid viewerGrid = ((Border)container.Children[1]).Child as Grid;
    
                // Add an element for custom view
                Border B = new Border() { Background = new SolidColorBrush(Colors.Cyan), Height = 200, Width = 200 };
                Grid.SetColumn(B, 1);
                Grid.SetColumnSpan(B, 2);
                Canvas.SetZIndex(B, Canvas.GetZIndex(viewerGrid.Children[0]) - 1);
                viewerGrid.Children[0].Visibility = Visibility.Collapsed;
                viewerGrid.Children.Add(B);
    
                // Add an element into the control bar
                Border B2 = new Border() { Background = new SolidColorBrush(Colors.Cyan), Width = 100, HorizontalAlignment=HorizontalAlignment.Right, VerticalAlignment=VerticalAlignment.Top };
                B2.Margin = new Thickness(0, 4, 6, 0);
                B2.Height = MyPV.PartZoomSlider.ActualHeight;
                Grid.SetColumn(B2, 0); // 2 = view buttons
                Grid.SetRow(B2, 0);
                Canvas.SetZIndex(B2, Canvas.GetZIndex(ctrlbar.Children[0]) - 1);
                ctrlbar.Children[0].Visibility = Visibility.Collapsed; // rectangle
                ctrlbar.Children.Add(B2);
    
     I'll blog it and upload a sample when I get a chance!
    Wednesday, January 11, 2012 1:47 PM
  • It is pretty similar to your earlier example, but please, include the rest of the code so we can see what you are doing. I have modified this and placed it in a control that inherets PivotViewer. Notice it is doing exactly the same thing as your code, but clearly grabs all the necessary internals first:

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
    
        var partContainer = (Grid)this.GetTemplateChild("PART_Container");
        var zoomSlider = (ClickDragSlider) this.GetTemplateChild("PART_ZoomSlider");           
        var controlBar = ((Grid)partContainer.Children[1]);
        var collectionViewerView = ((CollectionViewerView)partContainer.Children[2]);
        var container = collectionViewerView.Content as Grid;
        var viewerGrid = ((Border)container.Children[1]).Child as Grid;
        var collectionViewContainer = (CollectionViewContainer)viewerGrid.Children[0];
    
        // Add an element for custom view 
        Border B = new Border() { Background = new SolidColorBrush(Colors.Cyan), Height = 200, Width = 200 };
        Grid.SetColumn(B, 1);
        Grid.SetColumnSpan(B, 2);
        Canvas.SetZIndex(B, Canvas.GetZIndex(viewerGrid.Children[0]) - 1);
        viewerGrid.Children[0].Visibility = Visibility.Collapsed;
        viewerGrid.Children.Add(B);
    
        // Add an element into the control bar 
        Border B2 = new Border() { Background = new SolidColorBrush(Colors.Cyan), Width = 100, HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Top };
        B2.Margin = new Thickness(0, 4, 6, 0);
        B2.Height = zoomSlider.ActualHeight;
        Grid.SetColumn(B2, 0); // 2 = view buttons 
        Grid.SetRow(B2, 0);
        Canvas.SetZIndex(B2, Canvas.GetZIndex(controlBar.Children[0]) - 1);
        controlBar.Children[0].Visibility = Visibility.Collapsed; // rectangle 
        controlBar.Children.Add(B2);
    }

     This does show an aqua square, but then it just crashes.

     

     

     

     

    Wednesday, January 11, 2012 6:53 PM
  • I got a DataGrid in the PivotViewer.

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
    
        var partContainer = (Grid)this.GetTemplateChild("PART_Container");
        var zoomSlider = (ClickDragSlider) this.GetTemplateChild("PART_ZoomSlider");           
        var controlBar = ((Grid)partContainer.Children[1]);
        var collectionViewerView = ((CollectionViewerView)partContainer.Children[2]);
        var container = collectionViewerView.Content as Grid;
        var viewerGrid = ((Border)container.Children[1]).Child as Grid;
        var collectionViewContainer = (CollectionViewContainer)viewerGrid.Children[0];
        var detailView = (Grid)viewerGrid.Children[4];
    
        //Hide the tiles
        detailView.Children[0].Visibility = System.Windows.Visibility.Collapsed;
    
        //Create a DataGrid
        var dataGrid = new DataGrid();
        //Add a Group column (This will depend on what your dataset is like)
        dataGrid.Columns.Add(new DataGridTextColumn { Header = "Group", Binding = new Binding("Group"), Width = new DataGridLength(300) });
        Grid.SetColumn(dataGrid, 0);
        Grid.SetColumnSpan(dataGrid, 1);
        Canvas.SetZIndex(dataGrid, Canvas.GetZIndex(detailView.Children[0]) - 1);
    
        //Bind the items in the grid to the "InScopeItems" in the PivotViewer
        dataGrid.SetBinding(DataGrid.ItemsSourceProperty,new Binding("InScopeItems"));
        
        //Put the data grid in the PivotViewer
        detailView.Children.Insert(0, dataGrid);
    }
    Wednesday, January 11, 2012 7:28 PM
  • Double Post

    Wednesday, January 11, 2012 8:54 PM
  • OK. Here is a much more powerful version:

    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Controls.Pivot;
    using System.Windows.Data;
    using Microsoft.Internal.Pivot.Views;
    
    namespace PivotViewerTest
    {
        public class AdaptPivotViewer : PivotViewer
        {
            /// <summary>
            /// The DataTemplate to define what you want to appear in the detail area
            /// </summary>
            public DataTemplate ViewTemplate { get; set; }
    
            /// <summary>
            /// The ItemsSource property on the DataTemplate control to bind the PivotViewer's InScopeItems to
            /// </summary>
            public string ItemsSourcePropertyName { get; set; }
    
            /// <summary>
            /// Renders the display
            /// </summary>
            public override void OnApplyTemplate()
            {
                base.OnApplyTemplate();
    
                var partContainer = (Grid)this.GetTemplateChild("PART_Container");
                var collectionViewerView = ((CollectionViewerView)partContainer.Children[2]);
                var container = collectionViewerView.Content as Grid;
                var viewerGrid = ((Border)container.Children[1]).Child as Grid;
                var detailView = (Grid)viewerGrid.Children[4];
    
                //Hide the tiles
                detailView.Children[0].Visibility = System.Windows.Visibility.Collapsed;
    
                //Load the content of the DataTemplate
                var content = (Control) ViewTemplate.LoadContent();
                Grid.SetColumnSpan(content, 2); 
    
                //Get the dependency property to sync the InScopeItems with the items in the DataTemplate
                var dp = (DependencyProperty)content.GetType().GetField(ItemsSourcePropertyName + "Property", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public |  System.Reflection.BindingFlags.FlattenHierarchy).GetValue(null);
    
                //Sync the InScopeItems with the items in the DataTemplate
                ((Control)content).SetBinding(dp, new Binding("InScopeItems"));
    
                //Put the DataTemplate content in the PivotViewer
                detailView.Children.Insert(0, (UIElement) content);
            }
        }
    }
    
    

    You can defnie a DataTemplate and stick whatever you want to be displayed inside the PivotViewer (e.g. DataGrid, ListBox, whatever). The ViewTemplate defines what to display, and the ItemsSourcePropertyName tells the control which property to Sync with the PivotViewer. Here is some example xaml that works with a DataGrid or ListBox

    <UserControl xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"  xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="PivotViewerTest.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:pivot="clr-namespace:System.Windows.Controls.Pivot;assembly=System.Windows.Controls.Pivot"
                 xmlns:p="clr-namespace:PivotViewerTest"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
    
        <Grid x:Name="LayoutRoot" Background="White">
            <p:AdaptPivotViewer x:Name="theViewer" ItemsSourcePropertyName="ItemsSource"     >
    
                <p:AdaptPivotViewer.ViewTemplate>
                    <DataTemplate>
                        <!--<sdk:DataGrid  >
                        </sdk:DataGrid>-->
    
                        <ListBox  >
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Group}"></TextBlock>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
    
                    </DataTemplate>
                </p:AdaptPivotViewer.ViewTemplate>
    
                <pivot:PivotViewer.PivotProperties>
                    <pivot:PivotViewerStringProperty Id="Code" Options="CanSearchText" DisplayName="Code" Binding="{Binding Code}" />
                    <pivot:PivotViewerStringProperty Id="Description" Options="CanSearchText" DisplayName="Description" Binding="{Binding Description}" />
                    <pivot:PivotViewerStringProperty Id="Type" Options="CanFilter" DisplayName="Cost Type" Binding="{Binding Type}" />
                    <pivot:PivotViewerStringProperty Id="Group" Options="CanFilter" DisplayName="Group" Binding="{Binding Group}" />
                    <pivot:PivotViewerNumericProperty Id="Rate" Options="CanFilter" DisplayName="Rate" Binding="{Binding Rate}" />
                    <pivot:PivotViewerStringProperty Id="UnitType" Options="CanFilter" DisplayName="UnitType" Binding="{Binding UnitType}" />
                    <pivot:PivotViewerStringProperty Id="SubGroup" Options="CanFilter" DisplayName="SubGroup" Binding="{Binding SubGroup}" />
                </pivot:PivotViewer.PivotProperties>
    
            </p:AdaptPivotViewer>
        </Grid>
    </UserControl>
    
    
    The main problem left now, is that what you see in the pivot viewer is a rendered image of the DataGrid, not the actual DataGrid. 
    Can someone please tell me how we can display the actual grid rather than an image of the grid?

     

     

    Wednesday, January 11, 2012 8:55 PM
  • There is also a property on the PivotViewer called GridView. It is read only and only accepts objects of type PivotViewerGridView but that is an abstract class. I can't really figure out what this property is for. Has this got anything to do with displaying items in a DataGrid view style? The Microsoft doco says nothing about this.

    Anyway, is there a way to interact with the detail items in the PivotViewer? I have seen some samples where you can actually click on a button inside the tiles. I need to be able put a context menu on the rows inside the DataGrid and be able select items inside the DataGrid. Please help. Here is an example of a PivotViewer which has buttons on the tiles:

    http://www.physiotherapyexercises.com/ (You have to go through a few screens to get to the pivot) <- Edit - It looks like they'ved taken the Silverlight portion off the site...

    Wednesday, January 11, 2012 9:49 PM
  • A few quick notes:

    The buttons are custom actions and are a standard part of the PV control.

    http://msdn.microsoft.com/en-us/library/system.windows.controls.pivot.ipivotvieweruicommand(v=VS.95).aspx

    http://msdn.microsoft.com/en-us/library/system.windows.controls.pivot.pivotvieweritemadorner(v=VS.95).aspx

    Chris Arnold: http://goodcoffeegoodcode.wordpress.com/2011/10/28/customactions-itemadorners-in-pivotviewer-v2/

    If your datagrid cannot get focus it is because another transparent UIElement is in front of it. You will need to hide/show custom views, adjust Z-order, when the standard view buttons are clicked or remove the standard buttons and handle all view actions in a set of custom buttons.

    I usually add custom view buttons on early in the PV control lifetime (on applytemplate) but manipulate the custom views only when a button action is triggered, hence your earlier crash as not all the PV UIElement exist when onapplytemplate is triggered. Also, the UIElements change at runtime depending upon the collection, active view and other interactions.

    Thursday, January 12, 2012 3:53 AM
  • Thanks for the button links. That's just what the doctor ordered.

    If your datagrid cannot get focus it is because another transparent UIElement is in front of it. You will need to hide/show custom views, adjust Z-order

    That's what I thought at first, but the ZIndex is 500 so unless there is something higher than that in front of the DataGrid, this is not the case.

    I usually add custom view buttons on early in the PV control lifetime (on applytemplate) but manipulate the custom views only when a button action is triggered

    Fair enough. I tried doing this but it made no difference. I still can't interact with the DataGrid.

    I still tend to think that the PV is actually rendering the contents as an image in the same way that it renders the tile templates as images. Any more ideas?

    Thursday, January 12, 2012 6:26 PM
  • Nice to hear you are making good progress and learning lots, wish I had more time to help!

    I replaced the dynamically added Border element by a TextBox and when added into the PV control visual tree it works as expected, gets focus, enter text... Try that for yourself and if that works then you will need to work on your DataGrid generated in code. When I do this I usually work in a test project away from PV and only integrate into a PV project when I'm sure everything is working.

    Definitely move the DataGrid loading out of the OnApplyTemplate as you will find that occasionally the PV visual tree is not yet all there causing it to crash. From a button action I need to collapse the 'standard' view UIElements like below. The problem with the sample code is that the 'Children' change at runtime and a hardcoded '[0]' is insufficient, needing more robust code.

     

    viewerGrid.Children[0].Visibility = Visibility.Collapsed;
    
    Friday, January 13, 2012 4:35 AM
  • From what I've learned, if you "add" a datagrid to the visualtree in the "Loaded" event code of your Custom Pivot, and you call UpdateLayout() it won't crash:

    public CustomPivotViewer()
    {

    DataGridView = new DataGrid();

    DataGridViewBt = new DataGridViewButton();

    this.Loaded += new RoutedEventHandler(CustomPivotViewer_Loaded);

    DataGridViewBt.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(DataGridViewButton_MouseLeftButtonUp);

                }
    
    
    public void CustomPivotViewer_Loaded(object sender, RoutedEventArgs e)
    {
    this.UpdateLayout();
                //acesses the visual tree and inserts a previously created DataGrid
                InsertDataGridViewButton( DataGridViewBt );
    
    
                //acesses the visual tree and inserts a previously created DataGrid
                InsertDataGridView( DataGridView);

    }
    
    
    I have this running in a mvvm app
    Friday, January 13, 2012 11:28 AM
  • I replaced the dynamically added Border element by a TextBox and when added into the PV control visual tree it works as expected, gets focus, enter text...

    I tried a textbox. It was the same result as a DataGrid.

    Definitely move the DataGrid loading out of the OnApplyTemplate as you will find that occasionally the PV visual tree is not yet all there causing it to crash.

    I've moved the code to a button click event.

    Could you please post your test code? Perhaps you are replacing a different border element or something.

    Here is my code at the moment:

    public override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
    
        partContainer = (Grid)this.GetTemplateChild("PART_Container");
        collectionViewerView = ((CollectionViewerView)partContainer.Children[2]);
        container = collectionViewerView.Content as Grid;
        viewerGrid = ((Border)container.Children[1]).Child as Grid;
        detailView = (Grid)viewerGrid.Children[4];
    }
    
    public void Switch()
    {
        //Hide the tiles
        detailView.Children[0].Visibility = System.Windows.Visibility.Collapsed;
        detailView.Children.Insert(0, new TextBox());
    }

    The switch method is then called by an external button click event handler. Am I hiding the right element?

     

    Sunday, January 15, 2012 8:11 PM
  • Th code I used for the textbox:

    TextBox T = new TextBox() { Background = new SolidColorBrush(Colors.Blue), Height = 200, Width = 200 };
    Grid.SetColumn(T, 1);
    Grid.SetColumnSpan(T, 2);
    Canvas.SetZIndex(T, Canvas.GetZIndex(viewerGrid.Children[0]) - 1);
    viewerGrid.Children[0].Visibility = Visibility.Collapsed;
    viewerGrid.Children.Add(T);

    Hope that works ok as a test. The SetZIndex is needed.

    Monday, January 16, 2012 3:02 AM
  • This worked great!

            public void showDataGrid()
            {
                var partContainer = (Grid)this.GetTemplateChild("PART_Container");
                var collectionViewerView = ((CollectionViewerView)partContainer.Children[2]);
                var container = collectionViewerView.Content as Grid;
                var viewerGrid = ((Border)container.Children[1]).Child as Grid;
                var detailView = (Grid)viewerGrid.Children[4];

                detailView.Children[0].Visibility = System.Windows.Visibility.Collapsed;
                var content = (Control)ViewTemplate.LoadContent();
                Grid.SetColumn(content, 1);
                Grid.SetColumnSpan(content, 2);
                Canvas.SetZIndex(content, Canvas.GetZIndex(viewerGrid.Children[0]) - 1);
                viewerGrid.Children[0].Visibility = Visibility.Collapsed;
                var dp = (DependencyProperty)content.GetType().GetField(ItemsSourcePropertyName + "Property", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.FlattenHierarchy).GetValue(null);
                ((Control)content).SetBinding(dp, new Binding("InScopeItems"));
                viewerGrid.Children.Add(content);
            }
            public void hideDataGrid()
            {
                var partContainer = (Grid)this.GetTemplateChild("PART_Container");
                var collectionViewerView = ((CollectionViewerView)partContainer.Children[2]);
                var container = collectionViewerView.Content as Grid;
                var viewerGrid = ((Border)container.Children[1]).Child as Grid;
                var detailView = (Grid)viewerGrid.Children[4];

                detailView.Children[0].Visibility = System.Windows.Visibility.Visible;
                var content = (Control)ViewTemplate.LoadContent();
                viewerGrid.Children.RemoveAt(5);
                viewerGrid.Children[0].Visibility = Visibility.Visible;
            }

    Any thoughts/code on integrating this with the Grid/Graph view buttons?

    Thanks guys!

    Friday, January 20, 2012 2:17 PM
  • The way you insert the Control, will not allow the user to interact with the control. Try the following below.

    //Put the DataTemplate content in the PivotViewer
    //detailView.Children.Insert(0, (UIElement)content);
    
    viewerGrid.Children.Add(content);
    Grid.SetColumn(content, 1);
    content.Margin = new Thickness(5);
    viewerGrid.ColumnDefinitions[2].Width = new GridLength(0);
    Wednesday, February 15, 2012 2:33 PM
  • hi Xpert360,

    I used static pivotviewer and added custom action buttons. It works fine, but Now I use jit( just in time server) and I want to add custom action buttons, but it gives error "System.Windows.Markup.XamlParseException:The type 'MovingDoubleClickButton' was not found." and "Set property 'System.Windows.FrameworkElement.Style' threw an exception" in the view detail. how I can I solve this problem or how  can I add custom action buttons in jit. 

    Thanks

    Monday, May 14, 2012 2:29 AM
  • I find Problem. pivot.dll and sharedUI.dll( I addeed jit server) have different versions because of this give error.

    thanks

    Tuesday, May 15, 2012 6:48 AM
  • I was able to have my datagrid interact with grid/graph button kind of (basically creates a mutally exclusive view, ie. when my datagrid view is selected, the grid/graph buttons arent highlighted) so I figured I would share this in case others may still be trying to do something similar using a lot of the code from above posts:

    public override void OnApplyTemplate()
    {
    	base.OnApplyTemplate();
    	DGButton = new DataGridButton();
    	DGButton.DataGridClicked += new EventHandler(DataGridButtonClicked);
    	PVGrid = new PivotDataGrid(this.InScopeItems);
    	PVGrid.Visibility = Visibility.Collapsed;
    	Grid controlGrid = (Grid)GetTemplateChild("PART_ControlBar");
    	ListBox viewList = (ListBox)GetTemplateChild("PART_ViewSelector");
    	viewList.MouseLeftButtonUp += new MouseButtonEventHandler(OrginalViewClicked);
    	int viewSelectorIndex = Grid.GetColumn(viewList);
    	int col = 0;
    	foreach (FrameworkElement fe in controlGrid.Children)
    	{
    		col = Grid.GetColumn(fe);
    		if (col >= viewSelectorIndex)
    		{
    			Grid.SetColumn(fe, col + 1);
    		}
    	}
    	controlGrid.Children.Add(DGButton);
    	Grid.SetColumn(DGButton, viewSelectorIndex);
    }
    private void OrginalViewClicked(object sender, MouseButtonEventArgs e)
    {
    	var partContainer = (Grid)this.GetTemplateChild("PART_Container");
    	var collectionViewerView = ((CollectionViewerView)partContainer.Children[2]);
    	var container = collectionViewerView.Content as Grid;
    	var viewerGrid = ((Border)container.Children[1]).Child as Grid;
    	var detailView = (Grid)viewerGrid.Children[4];
    	DGButton.GridIsSelected = false;
    	if (detailView.Children[0].Visibility == Visibility.Collapsed)
    	{
    		DGButton.LayoutRoot.Background = new SolidColorBrush(Color.FromArgb(0, 217, 217, 217));
    		detailView.Children[0].Visibility = Visibility.Visible;
    		viewerGrid.Children.RemoveAt(5);
    		viewerGrid.Children[0].Visibility = Visibility.Visible;
    	}
    }
    private void DataGridButtonClicked(object sender, EventArgs e)
    {
    	var partContainer = (Grid)this.GetTemplateChild("PART_Container");
    	var collectionViewerView = ((CollectionViewerView)partContainer.Children[2]);
    	var container = collectionViewerView.Content as Grid;
    	var viewerGrid = ((Border)container.Children[1]).Child as Grid;
    	var detailView = (Grid)viewerGrid.Children[4];
    	if (detailView.Children[0].Visibility != Visibility.Collapsed)
    	{
    		ListBox viewList = (ListBox)GetTemplateChild("PART_ViewSelector");
    		StackPanel listItems = GetChildObject<StackPanel>(viewList);
    		for (int i = 0; i < listItems.Children.Count; i++)
    		{
    			ListBoxItem lbi = (ListBoxItem)listItems.Children[i];
    			Grid rectContainer = GetChildObject<Grid>(lbi);
    			for (int j = 0; j < 3; j++)
    			{
    				Rectangle currRect = (Rectangle)rectContainer.Children[j];
    				currRect.Opacity = 0;
    			}
    			Border currBorder = (Border)rectContainer.Children[4];
    			currBorder.Opacity = 0;
    		}
    		DGButton.GridIsSelected = true;
    		DGButton.LayoutRoot.Background = new SolidColorBrush(Color.FromArgb(255, 217, 217, 217));
    		detailView.Children[0].Visibility = Visibility.Collapsed;
    		var content = (Control)GridTemplate.LoadContent();
    		Grid.SetColumn(content, 1);
    		Grid.SetColumnSpan(content, 2);
    		Canvas.SetZIndex(content, Canvas.GetZIndex(viewerGrid.Children[0]) - 1);
    		viewerGrid.Children[0].Visibility = Visibility.Collapsed;
    		var dp = (DependencyProperty)content.GetType().GetField(ItemsSourcePropertyName + "Property", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.FlattenHierarchy).GetValue(null);
    		((Control)content).SetBinding(dp, new Binding("InScopeItems"));
    		viewerGrid.Children.Add(content);
    		
    	}
    }

    Monday, June 03, 2013 7:37 PM