Example #1
0
        private void BindItems()
        {
            _updating = true;

            try {
                _items = new ObservableCollection <DataTemplateItem>();
                var nullItem = new DataTemplateItem(null, false)
                {
                    Name = "<< none >>", Object = null
                };
                _items.Add(nullItem);

                foreach (var a in _tempMgr.Templates.Where(t => t.TypeName == _type.FullName))
                {
                    _items.Add(new DataTemplateItem(a, _tempMgr.IsDefault(a.TypeName, a.Name)));
                }

                cbTemps.ItemsSource       = _items;
                cbTemps.DisplayMemberPath = "DisplayName";
                cbTemps.SelectedValuePath = "Object";
                cbTemps.SelectedValue     = nullItem;

                cbTemps.SelectedIndex = 0;
            } finally {
                _updating = false;
            }
        }
Example #2
0
        public bool StubComponent(string ComponentName, string LayerName)
        {
            var renderingParent = _contentRepository.GetItem <ISitecoreItem>(new GetItemByPathOptions {
                Path = $"/sitecore/layout/Renderings/{LayerName}"
            });
            var renderingChild = new ControllerRenderingItem
            {
                Name = ComponentName
            };

            var dataTemplateParent = _contentRepository.GetItem <ISitecoreItem>(new GetItemByPathOptions {
                Path = $"/sitecore/templates/{LayerName}"
            });
            var dataTemplateChild = new DataTemplateItem
            {
                Name = $"_{ComponentName}"
            };

            using (new SecurityDisabler())
            {
                //create the rendering
                _contentRepository.CreateItem(new CreateByModelOptions {
                    Model = renderingChild, Parent = renderingParent
                });

                //Create the interface template
                _contentRepository.CreateItem(new CreateByModelOptions {
                    Model = dataTemplateChild, Parent = dataTemplateParent
                });
            }

            return(true);
        }
    private void BindItems() {

      _updating = true;

      try {
        _items = new ObservableCollection<DataTemplateItem>();
        var nullItem = new DataTemplateItem(null, false) { Name = "<< none >>", Object = null };
        _items.Add(nullItem);

        foreach( var a in _tempMgr.Templates.Where(t => t.TypeName == _type.FullName) )
          _items.Add( new DataTemplateItem(a, _tempMgr.IsDefault(a.TypeName, a.Name) ) );

        cbTemps.ItemsSource = _items;
        cbTemps.DisplayMemberPath = "DisplayName";
        cbTemps.SelectedValuePath = "Object";
        cbTemps.SelectedValue = nullItem;

        cbTemps.SelectedIndex = 0;

      } finally {
        _updating = false;
      }
    }