TreeViewTemplateSelector.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Toolbox / TreeViewTemplateSelector.cs / 1305376 / TreeViewTemplateSelector.cs

                            //------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------

namespace System.Activities.Presentation.Toolbox 
{
    using System.Windows; 
    using System.Windows.Controls; 

    // This class is resposible for selecting proper template for Category and Tool objects 
    // (those entities have different values beeing displayed)

    sealed class TreeViewTemplateSelector : DataTemplateSelector
    { 
        ToolboxControl owner;
 
        public TreeViewTemplateSelector(ToolboxControl owner) 
        {
            this.owner = owner; 
        }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        { 
            DataTemplate result = base.SelectTemplate(item, container);
 
            if (item is ToolboxItemWrapper && null != this.owner.ToolTemplate) 
            {
                result = this.owner.ToolTemplate; 
            }
            if (item is ToolboxCategory && null != this.owner.CategoryTemplate)
            {
                result = this.owner.CategoryTemplate; 
            }
 
            return result; 
        }
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------

namespace System.Activities.Presentation.Toolbox 
{
    using System.Windows; 
    using System.Windows.Controls; 

    // This class is resposible for selecting proper template for Category and Tool objects 
    // (those entities have different values beeing displayed)

    sealed class TreeViewTemplateSelector : DataTemplateSelector
    { 
        ToolboxControl owner;
 
        public TreeViewTemplateSelector(ToolboxControl owner) 
        {
            this.owner = owner; 
        }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        { 
            DataTemplate result = base.SelectTemplate(item, container);
 
            if (item is ToolboxItemWrapper && null != this.owner.ToolTemplate) 
            {
                result = this.owner.ToolTemplate; 
            }
            if (item is ToolboxCategory && null != this.owner.CategoryTemplate)
            {
                result = this.owner.CategoryTemplate; 
            }
 
            return result; 
        }
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK