Example #1
0
        /// <summary>
        /// Called when the NodeModel's CachedValue property is updated
        /// </summary>
        private void CachedValueChanged()
        {
            Dispatcher.BeginInvoke(new Action(delegate
            {
                // There is no preview control or the preview control is
                // currently in transition state (it can come back to handle
                // the new data later on when it is ready).
                if ((previewControl == null))
                {
                    return;
                }

                // Enqueue an update of the preview control once it has completed its
                // transition
                if (previewControl.IsInTransition)
                {
                    previewControl.EnqueueBindToDataSource(ViewModel.NodeModel.CachedValue);
                    return;
                }

                if (previewControl.IsHidden) // The preview control is hidden.
                {
                    // Invalidate the previously bound data, if any.
                    if (previewControl.IsDataBound)
                    {
                        previewControl.BindToDataSource(null);
                    }
                    return;
                }

                previewControl.BindToDataSource(ViewModel.NodeModel.CachedValue);
            }));
        }