Ejemplo n.º 1
0
        private void RefreshExpandedDisplay()
        {
            // The preview control will not have its content refreshed unless
            // the content is null. In order to perform real refresh, new data
            // source needs to be rebound to the preview control by calling
            // BindToDataSource method.
            //
            if (this.cachedLargeContent != null)
            {
                return;
            }

            if (largeContentGrid.Children.Count <= 0)
            {
                var newWatchTree = new WatchTree();
                newWatchTree.DataContext = new WatchViewModel();
                largeContentGrid.Children.Add(newWatchTree);
            }

            var watchTree       = largeContentGrid.Children[0] as WatchTree;
            var rootDataContext = watchTree.DataContext as WatchViewModel;

            // Associate the data context to the view before binding.
            cachedLargeContent = Watch.Process(mirrorData, string.Empty, false);
            rootDataContext.Children.Add(cachedLargeContent);

            // Establish data binding between data context and the view.
            watchTree.treeView1.SetBinding(ItemsControl.ItemsSourceProperty,
                                           new Binding("Children")
            {
                Mode   = BindingMode.TwoWay,
                Source = rootDataContext
            });
        }