当前位置: 首页>>代码示例>>C#>>正文


C# TreeViewItem.SetValue方法代码示例

本文整理汇总了C#中System.Windows.Controls.TreeViewItem.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# TreeViewItem.SetValue方法的具体用法?C# TreeViewItem.SetValue怎么用?C# TreeViewItem.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.TreeViewItem的用法示例。


在下文中一共展示了TreeViewItem.SetValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WalkTreeViewItem

        public static bool WalkTreeViewItem(TreeView tree, TreeViewItem treeViewItem, object selectedValue)
        {
            if (treeViewItem.DataContext == selectedValue)
            {
                treeViewItem.SetValue(TreeViewItem.IsSelectedProperty, true);
                treeViewItem.Focus();
                treeViewItem.BringIntoView();
                return true;
            }
            var itemsHostProperty = treeViewItem.GetType().GetProperty("ItemsHost", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);

            var itemsHost = itemsHostProperty?.GetValue(treeViewItem, null) as Panel;

            if (itemsHost == null)
            {
                return false;
            }

            foreach (var item in itemsHost.Children.OfType<TreeViewItem>())
            {
                var oldExpanded = item.IsExpanded;
                item.IsExpanded = true;
                item.UpdateLayout();
                if (WalkTreeViewItem(tree, item, selectedValue))
                {
                    return true;
                }
                item.IsExpanded = oldExpanded;
            }

            return false;
        }
开发者ID:AnchoretTeam,项目名称:AppUpdate,代码行数:32,代码来源:BindableSelectedItemHelper.cs

示例2: GetConnectingLineInfo

        /// <summary>
        /// Gets the value of the ConnectingLineInfo attached property for a
        /// specified TreeViewItem.
        /// </summary>
        /// <param name="element">
        /// The TreeViewItem from which the property value is read.
        /// </param>
        /// <returns>
        /// The ConnectingLineInfo property value for the TreeViewItem.
        /// </returns>
        internal static TreeViewItemConnectingLineInfo GetConnectingLineInfo(TreeViewItem element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            
            // Get the info and create on demand if necessary
            TreeViewItemConnectingLineInfo info = element.GetValue(ConnectingLineInfoProperty) as TreeViewItemConnectingLineInfo;
            if (info == null)
            {
                info = new TreeViewItemConnectingLineInfo(element);
                element.SetValue(ConnectingLineInfoProperty, info);
            }

            return info;
        }
开发者ID:modulexcite,项目名称:SilverlightToolkit,代码行数:27,代码来源:TreeViewConnectingLines.cs

示例3: SetIsBroughtIntoViewWhenSelected

 public static void SetIsBroughtIntoViewWhenSelected(TreeViewItem treeViewItem, bool value)
 {
     treeViewItem.SetValue(IsBroughtIntoViewWhenSelectedProperty, value);
 }
开发者ID:huyettoc,项目名称:duycm-workstation,代码行数:4,代码来源:TreeViewItemBehavior.cs

示例4: SetIsTreeViewItemDropOver

 public static void SetIsTreeViewItemDropOver(TreeViewItem item, bool value)
 {
     item.SetValue(IsTreeViewItemDropOverProperty, value);
 }
开发者ID:jango2015,项目名称:VS-Macros,代码行数:4,代码来源:MacrosControl.xaml.cs

示例5: SetIsItemSelected

        public static void SetIsItemSelected(TreeViewItem element, Boolean value)
        {
            if (element == null) return;

            element.SetValue(IsItemSelectedProperty, value);
        }
开发者ID:CADblokeWPFforks,项目名称:MultiSelectTreeView-1,代码行数:6,代码来源:MultiSelectTreeView.cs

示例6: SetBringSelectionIntoView

 public static void SetBringSelectionIntoView(TreeViewItem treeViewItem, bool value)
 {
     treeViewItem.SetValue(BringSelectionIntoViewProperty, value);
 }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:4,代码来源:TreeViewItemDisplay.cs

示例7: SetIsFiltered

 public static void SetIsFiltered(TreeViewItem item, bool value)
 {
     item.SetValue(IsFilteredProperty, value);
 }
开发者ID:kswoll,项目名称:restless,代码行数:4,代码来源:TreeViewItemFilter.cs

示例8: SetEnableContextMenuWorkaround

 public static void SetEnableContextMenuWorkaround(
     TreeViewItem treeViewItem, bool value) {
     treeViewItem.SetValue(EnableContextMenuWorkaroundProperty, value);
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:4,代码来源:DataGridBehavior.cs

示例9: SetEnableFullRowSelection

 public static void SetEnableFullRowSelection(
     TreeViewItem treeViewItem, bool value) {
     treeViewItem.SetValue(EnableFullRowSelectionProperty, value);
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:4,代码来源:DataGridBehavior.cs

示例10: SetBringIntoViewWhenSelected

 public static void SetBringIntoViewWhenSelected(TreeViewItem treeViewItem, bool value)
 {
     treeViewItem.SetValue(BringIntoViewWhenSelectedProperty, value);
 }
开发者ID:Reddds,项目名称:ProjectExplorer,代码行数:4,代码来源:TreeViewItemBehavior.cs

示例11: SetIsChecked

        static void SetIsChecked(TreeViewItem item, bool? value, bool updateChildren, bool updateParent)
        {
            if (value == GetIsSelected(item))
                return;

            item.SetValue(IsSelectedProperty, value);

            if (updateChildren && value.HasValue)
            {
                foreach (var treeViewItem in GetChildren(item))
                {
                    SetIsChecked(treeViewItem,value, true, false);
                }
            }

            if (updateParent && GetParentTreeViewItem(item)!= null)
                VerifyCheckState(GetParentTreeViewItem(item));
        }
开发者ID:punker76,项目名称:sjupdater,代码行数:18,代码来源:TreeViewExtensions.cs

示例12: SetAssociatedToolbarItem

 /// <summary>
 /// Sets the value of the AssociatedToolbarItem attached property to a specified TreeViewItem.
 /// </summary>
 /// <param name="element">The TreeViewItem to which the attached property is written.</param>
 /// <param name="value">The needed AssociatedToolbarItem value.</param>
 internal static void SetAssociatedToolbarItem(TreeViewItem element, AddToolbarItem value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(AssociatedToolbarItemProperty, value);
 }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:13,代码来源:AddToolbarItem.cs

示例13: resource_GetChildResourcesCompleted

        void resource_GetChildResourcesCompleted(object sender, GetChildResourcesCompletedEventArgs e)
        {
            TreeViewItem tvi = null;
            string childName = "";

            object[] userState = e.UserState as object[];

            IDataSourceWithResources dataSource = userState[1] as IDataSourceWithResources;
            if (dataSource == null)
                return;

            // If the element at [0] is a tree view item, then this is a standard expand action on a parent node and
            // the logic flow is as it was before: remove current contents, add from array
            tvi = userState[0] as TreeViewItem;
            if (tvi != null)
            {
                tvi.Items.Clear();
            }
            else
            {
                // If the item we are adding to is the root (TreeView) then there are no children, but we are instead using the
                // progress indicator and must clear this here.
                showHideProgressIndicator(true);
                enableDisableUrlEntryUI(false);

                // Fabricate parent node and include connection, etc. so that when this node is expanded or child nodes are
                // referenced, the infrastructure will be in place to make existing logic work to obtain child information
                Resource parentResource = userState[2] as Resource;
                tvi = new TreeViewItem
                {
                    HeaderTemplate = LayoutRoot != null ? LayoutRoot.Resources["ResourceNodeDataTemplate"] as DataTemplate : null,
                    Header = parentResource,
                    DataContext = parentResource,
                    IsExpanded = true,
                    IsSelected = true,
                    Style = LayoutRoot != null ? LayoutRoot.Resources["TreeViewItemStyle"] as Style : null,
                };
                Connection connection = userState[3] as Connection;
                tvi.SetValue(TreeViewItemExtensions.ConnectionProperty, connection);
                treeResources.Items.Add(tvi);

                // If the parent item "tag" is assigned a value, store it for comparison against all child elements so that
                // the proper child element can be automatically selected. This is used when the URL contains the child
                // element of a map service, gp service, feature service, etc.
                if (parentResource.Tag != null)
                {
                    childName = parentResource.Tag as string;
                }
            }

            if (e.ChildResources == null)
                return;

            foreach (Resource childResource in e.ChildResources)
            {
                TreeViewItem treeViewItem = new TreeViewItem
                {
                    HeaderTemplate = LayoutRoot != null ? LayoutRoot.Resources["ResourceNodeDataTemplate"] as DataTemplate : null,
                    Header = childResource,
                    DataContext = childResource,
                    IsExpanded = false,
                    Style = LayoutRoot != null ? LayoutRoot.Resources["TreeViewItemStyle"] as Style : null,
                };
                if (childResource.ResourceType == ResourceType.Layer || childResource.ResourceType == ResourceType.EditableLayer)
                {
                    treeViewItem.SetValue(ToolTipService.ToolTipProperty, childResource.ResourceType == ResourceType.Layer ? Strings.MapLayer : Strings.FeatureLayer);
                }
                if (!string.IsNullOrWhiteSpace(childResource.DisplayName))
                {
                    string parentAutomationId = tvi.GetValue(System.Windows.Automation.AutomationProperties.AutomationIdProperty) as string;
                    if (parentAutomationId == null)
                        parentAutomationId = string.Empty;
                    treeViewItem.SetValue(System.Windows.Automation.AutomationProperties.AutomationIdProperty, parentAutomationId + childResource.DisplayName + childResource.ResourceType);
                }

                bool hasChildResource = dataSource.SupportsChildResources(childResource, filter);
                if (hasChildResource)
                {
                    treeViewItem.Items.Add(createRetrievingNode());
                    treeViewItem.Expanded += new RoutedEventHandler(resourceNode_Expanded);
                }

                // If a child Id was successfully extracted from the parent resource, this means there should be a child
                // resource with the same id and we need to select this as the initial URL indicated the desire to use
                // this child resource.
                if (!String.IsNullOrEmpty(childName))
                {
                    if (childResource.ResourceType == ResourceType.GPTool || childResource.ResourceType == ResourceType.DatabaseTable)
                    {
                        if (String.Compare(childName, childResource.DisplayName) == 0)
                            treeViewItem.IsSelected = true;
                    }
                    else if (childResource.ResourceType == ResourceType.Layer)
                    {
                        if (childResource.Tag != null)
                        {
                            int nodeId = (int)childResource.Tag;
                            string nodeName = String.Format("{0}", nodeId);
                            if (String.Compare(childName, nodeName) == 0)
                                treeViewItem.IsSelected = true;
//.........这里部分代码省略.........
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:101,代码来源:BrowseContentDialog.cs

示例14: dataSource_GetCatalogCompleted

        void dataSource_GetCatalogCompleted(object sender, GetCatalogCompletedEventArgs e)
        {
            enableDisableUrlEntryUI(false);

            object[] userState = e.UserState as object[];
            if (userState == null || userState.Length < 2)
                return;

            Connection connection = userState[0] as Connection;
            if (connection == null)
                return;

            if (e.ChildResources == null)
                return;

            if (treeResources == null)
                return;

            ESRI.ArcGIS.Mapping.Core.DataSources.DataSource ds = DataSourceProvider.CreateNewDataSourceForConnectionType(connection.ConnectionType);
            if (ds == null)
                return;

            IDataSourceWithResources dsWithResource = ds as IDataSourceWithResources;

            treeResources.Items.Clear();

            foreach (Resource childResource in e.ChildResources)
            {
                TreeViewItem treeViewItem = new TreeViewItem
                {
                    HeaderTemplate = LayoutRoot != null ? LayoutRoot.Resources["ResourceNodeDataTemplate"] as DataTemplate : null,
                    Header = childResource,
                    DataContext = childResource,
                    IsExpanded = false,
                    Style = LayoutRoot != null ? LayoutRoot.Resources["TreeViewItemStyle"] as Style : null,
                };
                if(!string.IsNullOrWhiteSpace(childResource.DisplayName))
                    treeViewItem.SetValue(System.Windows.Automation.AutomationProperties.AutomationIdProperty, childResource.DisplayName);
                
                treeViewItem.SetValue(TreeViewItemExtensions.ConnectionProperty, connection);
                if (dsWithResource != null && dsWithResource.SupportsChildResources(childResource, filter))
                {
                    treeViewItem.Items.Add(createRetrievingNode());
                    treeViewItem.Expanded += new RoutedEventHandler(resourceNode_Expanded);
                }
                treeResources.Items.Add(treeViewItem);
            }

            showHideProgressIndicator(true);
            bool addConnection = true;
            if (treeResources.Items.Count == 0)
            {
                if(!string.IsNullOrEmpty(e.Error))
                    MessageBoxDialog.Show(e.Error, ESRI.ArcGIS.Mapping.Controls.Resources.Strings.BrowseDialogGeographicDataNotFound, MessageBoxButton.OK);
                else if ((Filter & Filter.GeoprocessingServices) == Filter.GeoprocessingServices)
                    MessageBoxDialog.Show(string.Format(LocalizableStrings.NoGPServicesFound, connection.Name));
                else
                    MessageBoxDialog.Show(string.Format(LocalizableStrings.NoMapServicesFound, connection.Name));
                addConnection = false;
            }

            OnGetCatalogCompleted(e);
            bool isNewConnection = (bool)userState[1];
            if (isNewConnection)
            {
                if (addConnection)
                {
                    Connections.Add(connection);
                    if (ConnectionsProvider != null)
                        ConnectionsProvider.AddConnection(connection); // inform the provider about the new connection
                    OnConnectionAdded(new ConnectionAddedEventArgs() { Connection = connection });
                }
            }
        }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:74,代码来源:BrowseContentDialog.cs


注:本文中的System.Windows.Controls.TreeViewItem.SetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。