예제 #1
0
        public virtual void AddChild(MC.Element child, int physicalSiblingIndex)
        {
            if (child is null)
            {
                throw new ArgumentNullException(nameof(child));
            }

            MC.ShellItem itemToAdd = child switch
            {
                MC.TemplatedPage childAsTemplatedPage => childAsTemplatedPage,       // Implicit conversion
                         MC.ShellContent childAsShellContent => childAsShellContent, // Implicit conversion
                         MC.ShellSection childAsShellSection => childAsShellSection, // Implicit conversion
                         MC.MenuItem childAsMenuItem => childAsMenuItem,             // Implicit conversion
                         MC.ShellItem childAsShellItem => childAsShellItem,
                         _ => throw new NotSupportedException($"Handler of type '{GetType().FullName}' representing element type '{TargetElement?.GetType().FullName ?? "<null>"}' doesn't support adding a child (child type is '{child.GetType().FullName}').")
            };

            if (ShellControl.Items.Count >= physicalSiblingIndex)
            {
                ShellControl.Items.Insert(physicalSiblingIndex, itemToAdd);
            }
            else
            {
                Debug.WriteLine($"WARNING: {nameof(AddChild)} called with {nameof(physicalSiblingIndex)}={physicalSiblingIndex}, but ShellControl.Items.Count={ShellControl.Items.Count}");
                ShellControl.Items.Add(itemToAdd);
            }
        }
예제 #2
0
 private MC.ShellContent GetContentForChild(MC.Element child)
 {
     return(child switch
     {
         MC.TemplatedPage childAsTemplatedPage => GetContentForTemplatePage(childAsTemplatedPage),
         MC.ShellContent childAsShellContent => childAsShellContent,
         _ => null
     });
예제 #3
0
 private MC.ShellSection GetSectionForElement(MC.Element child)
 {
     return(child switch
     {
         MC.TemplatedPage childAsTemplatedPage => GetSectionForTemplatedPage(childAsTemplatedPage),
         MC.ShellContent childAsShellContent => GetSectionForContent(childAsShellContent),
         MC.ShellSection childAsShellSection => childAsShellSection,
         _ => null
     });
예제 #4
0
 private MC.ShellItem GetItemForElement(MC.Element child)
 {
     return(child switch
     {
         MC.TemplatedPage childAsTemplatedPage => GetItemForTemplatedPage(childAsTemplatedPage),
         MC.ShellContent childAsShellContent => GetItemForContent(childAsShellContent),
         MC.ShellSection childAsShellSection => GetItemForSection(childAsShellSection),
         MC.MenuItem childAsMenuItem => GetItemForMenuItem(childAsMenuItem),
         MC.ShellItem childAsShellItem => childAsShellItem,
         _ => null
     });
예제 #5
0
        public TemplatedPageHandler(NativeComponentRenderer renderer, MC.TemplatedPage templatedPageControl) : base(renderer, templatedPageControl)
        {
            TemplatedPageControl = templatedPageControl ?? throw new ArgumentNullException(nameof(templatedPageControl));

            Initialize(renderer);
        }