LoadContent() public method

public LoadContent ( ) : DependencyObject
return DependencyObject
Exemplo n.º 1
0
        void UpdateContent(Cell newCell)
        {
            Windows.UI.Xaml.DataTemplate dt = GetTemplate(newCell);
            if (dt != _currentTemplate || Content == null)
            {
                _currentTemplate = dt;
                Content          = dt.LoadContent();
            }

            ((FrameworkElement)Content).DataContext = newCell;
        }
        private Path CreateNewPath(Path oldPath, DataTemplate pathTemplate, int zIndex)
        {
            if (oldPath != null)
            {
                root.Children.Remove(oldPath);
            }

            if (pathTemplate != null)
            {
                var newPath = pathTemplate.LoadContent() as Path;
                if (newPath != null)
                {
                    root.Children.Add(newPath);
                    Canvas.SetZIndex(newPath, zIndex);
                    return newPath;
                }
            }

            return null;
        }
Exemplo n.º 3
0
        UIElement GetTemplatedCell(DataGrid grid, DataTemplate dt)
        {

            // check that the grid requesting the cell is the cache owner
            if (_cacheOwner == null)
            {
                _cacheOwner = grid;
            }

            // get from cache if possible
            List<UIElement> list = null;


            // not the cache owner? don't use the cache...
            if (grid == _cacheOwner)
            {
                if (_dtCache.TryGetValue(dt, out list) && list.Count > 0)
                {
                    foreach (var item in list)
                    {
                        if (VisualTreeHelper.GetParent(item) == null)
                        {
                            return item;
                        }
                    }
                }
            }
            // create now
            var e = dt.LoadContent() as UIElement;
            // save in recycle list
            if (e != null)
            {
                // not the cache owner? don't use the cache...
                if (grid == _cacheOwner)
                {
                    if (list == null)
                    {
                        list = new List<UIElement>();
                        _dtCache[dt] = list;
                    }
                    list.Add(e);
                    _dtRawCache[e] = true;
                }
            }
            // return
            return e;
        }