Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

TreeView not recognizing new images and view models when hosted in a VSPackage

$
0
0

I have a WPF user control that is hosted by a windows application and a VSPackage ToolWindow. This user control contains a TreeView with various kinds of nodes and associated images, and utilizes the MVVM pattern to bind the items.

The following illustrates the control hosted within the windows application:

The ToolWindow version of this control has been behaving as expected for a long time. However, after adding additional features to this control, I'm seeing the following symptoms:

  1. New view models are not being recognized in the TreeView.
  2. New image file names are not being recognized in the TreeView.

The following illustrates the same control hosted within the ToolWindow (see missing images under Collections and Diagrams, and unrecognized view model under Workflows):


When debugging the ToolWindow version, all of the expected view model data is present, and other new features besides the TreeView display are operating as expected.

Here is some sample XAML from the TreeView control:

<UserControl.Resources><ResourceDictionary><BitmapImage x:Key="Icon_FolderOpen"   UriSource="pack://siteOfOrigin:,,,/Resources/Images/FolderOpen.ico"   /><BitmapImage x:Key="Icon_FolderClosed" UriSource="pack://siteOfOrigin:,,,/Resources/Images/FolderClosed.ico" /><BitmapImage x:Key="Icon_DiagramClosed" UriSource="pack://siteOfOrigin:,,,/Resources/Images/DiagramClosed.ico" /><BitmapImage x:Key="Icon_CollectionClosed" UriSource="pack://siteOfOrigin:,,,/Resources/Images/CollectionClosed.ico" /><BitmapImage x:Key="Icon_EntityOpen"   UriSource="pack://siteOfOrigin:,,,/Resources/Images/EntityOpen.ico"   /><BitmapImage x:Key="Icon_EntityClosed" UriSource="pack://siteOfOrigin:,,,/Resources/Images/EntityClosed.ico" /><BitmapImage x:Key="Icon_WorkflowOpen"   UriSource="pack://siteOfOrigin:,,,/Resources/Images/WorkflowOpen.ico"   /><BitmapImage x:Key="Icon_WorkflowClosed" UriSource="pack://siteOfOrigin:,,,/Resources/Images/WorkflowClosed.ico" /><!-- Diagrams --><HierarchicalDataTemplate DataType="{x:Type Diagrams:DiagramsViewModel}" ItemsSource="{Binding Items, Mode=OneWay}"><StackPanel Orientation="Horizontal"><Image x:Name="nodeImg" Style="{StaticResource IconImageStyleSmall}" Source="{StaticResource Icon_FolderClosed}" /><TextBlock Style="{DynamicResource TreeViewItemTextStyle}" /></StackPanel><HierarchicalDataTemplate.Triggers><DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=lib:ModelTreeViewItem}, Path=IsExpanded}" Value="True"><Setter TargetName="nodeImg" Property="Source" Value="{Binding Source={StaticResource Icon_FolderOpen}, Mode=OneTime}"/></DataTrigger></HierarchicalDataTemplate.Triggers></HierarchicalDataTemplate><!-- Diagram --><DataTemplate DataType="{x:Type Diagrams:DiagramViewModel}"><StackPanel Orientation="Horizontal"><Image x:Name="nodeImg" Style="{StaticResource IconImageStyleSmall}" Source="{StaticResource Icon_DiagramClosed}" /><TextBlock Style="{DynamicResource TreeViewItemTextStyle}" /></StackPanel></DataTemplate><!-- Collections --><HierarchicalDataTemplate DataType="{x:Type Entities:CollectionsViewModel}" ItemsSource="{Binding Items, Mode=OneWay}"><StackPanel Orientation="Horizontal"><Image x:Name="nodeImg" Style="{StaticResource IconImageStyleSmall}" Source="{StaticResource Icon_FolderClosed}" /><TextBlock Style="{DynamicResource TreeViewItemTextStyle}" /></StackPanel><HierarchicalDataTemplate.Triggers><DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=lib:ModelTreeViewItem}, Path=IsExpanded}" Value="True"><Setter TargetName="nodeImg" Property="Source" Value="{Binding Source={StaticResource Icon_FolderOpen}, Mode=OneTime}"/></DataTrigger></HierarchicalDataTemplate.Triggers></HierarchicalDataTemplate><!-- Collection --><DataTemplate DataType="{x:Type Entities:CollectionViewModel}"><StackPanel Orientation="Horizontal"><Image x:Name="nodeImg" Style="{StaticResource IconImageStyleSmall}" Source="{StaticResource Icon_CollectionClosed}" /><TextBlock Style="{DynamicResource TreeViewItemTextStyle}" /></StackPanel></DataTemplate><!-- Workflows --><HierarchicalDataTemplate DataType="{x:Type Workflows:WorkflowsViewModel}" ItemsSource="{Binding Items, Mode=OneWay}"><StackPanel Orientation="Horizontal"><Image x:Name="nodeImg" Style="{StaticResource IconImageStyleSmall}" Source="{StaticResource Icon_FolderClosed}" /><TextBlock Style="{DynamicResource TreeViewItemTextStyle}" /></StackPanel><HierarchicalDataTemplate.Triggers><DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=lib:ModelTreeViewItem}, Path=IsExpanded}" Value="True"><Setter TargetName="nodeImg" Property="Source" Value="{Binding Source={StaticResource Icon_FolderOpen}, Mode=OneTime}"/></DataTrigger></HierarchicalDataTemplate.Triggers></HierarchicalDataTemplate><!-- Workflow --><HierarchicalDataTemplate DataType="{x:Type Workflows:WorkflowViewModel}" ItemsSource="{Binding Items, Mode=OneWay}"><StackPanel Orientation="Horizontal"><Image x:Name="nodeImg" Style="{StaticResource IconImageStyleSmall}" Source="{StaticResource Icon_WorkflowClosed}" /><TextBlock Style="{DynamicResource TreeViewItemTextStyle}" /></StackPanel><HierarchicalDataTemplate.Triggers><DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=lib:ModelTreeViewItem}, Path=IsExpanded}" Value="True"><Setter TargetName="nodeImg" Property="Source" Value="{Binding Source={StaticResource Icon_WorkflowOpen}, Mode=OneTime}"/></DataTrigger></HierarchicalDataTemplate.Triggers></HierarchicalDataTemplate></ResourceDictionary></UserControl.Resources><Grid><lib:ModelTreeView VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" ItemsSource="{Binding Items, Mode=OneWay}" /></Grid>

What is a possible cause of this issue? I've reset the VStudio experimental hive, even given new GUIDs for the package elements, etc.




Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>