This is a migrated thread and some comments may be shown as answers.

Errors when trying to bind RadTreeView to CollectionViewSource with a ViewModel source

1 Answer 99 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mariano
Top achievements
Rank 1
Mariano asked on 05 Oct 2010, 09:07 PM
I´m working on an app with the following architecture, I´m using CSLA .NET 4, BXF for plumbing to MVVM and WPF.

Files code follow:

TreeviewView.xaml
------------------------
<UserControl x:Class="MyAppDesktopWPF.TreeviewView"       
         
         
xmlns:Telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
        xmlns:csla="clr-namespace:Csla.Data;assembly=Csla"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400"
Loaded="UserControl_Loaded"
xmlns:my="clr-namespace:MyAppDesktopWPF.ViewModels">

<UserControl.Resources>

<
CollectionViewSource x:Key="TreeAreaDS" Source="{Binding
Source={StaticResource TrashViewModel},
Path=Model}"></CollectionViewSource>

<
HierarchicalDataTemplate x:Key="ToolsDataTemplate"ItemsSource="{Binding Tools}" >
            <TextBlock Text="{Binding Path=Name}" FontWeight="Bold"/>
</
HierarchicalDataTemplate>

        <HierarchicalDataTemplate x:Key="SegmentsDataTemplate"
ItemsSource="{Binding Segments}" ItemTemplate="{StaticResource ToolsDataTemplate}" >
            <TextBlock Text="{Binding Path=Name}" FontWeight="Bold"/>
        </HierarchicalDataTemplate>

        <HierarchicalDataTemplate  x:Key="SectionsDataTemplate" 
ItemsSource="{Binding Sections}" ItemTemplate="{StaticResource
SegmentsDataTemplate}">
            <TextBlock Text="{Binding Path=Name}"
FontWeight="Bold"/>
        </HierarchicalDataTemplate>

    </UserControl.Resources>

<Telerik:RadTreeView ItemsSource="{Binding Source={StaticResource
TreeAreaDS}}" ItemTemplate="{StaticResource SectionsDataTemplate}"
Name="PlanTreeView" Height="250" HorizontalAlignment="Left" Margin="3"
VerticalAlignment="Center" Width="150" />

TrashViewModel.cs
------------------------
public class TrashViewModel : ViewModel<MyAppBO.MyClass>
    {
        public TrashViewModel()
        {
            Bxf.Shell.Instance.ShowStatus(new Bxf.Status { Text =
"Getting Plan", IsBusy = true });
            ManageObjectLifetime = true;
            // cascade model changed events through VM to View
            Model.PropertyChanged += (o, e) =>
OnPropertyChanged(e.PropertyName);
        }

        public TrashViewModel(MyClass classInstance)
        {
            Bxf.Shell.Instance.ShowStatus(new Bxf.Status { Text =
"Getting Plan", IsBusy = true });
            ManageObjectLifetime = true;
            Model = classInstance;

            // cascade model changed events through VM to View<br>
            Model.PropertyChanged += (o, e) =>
OnPropertyChanged(e.PropertyName);
        }


With this version of the code I get an exception that says:
"'Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception.' Line number '108' and line position '50'."
---------------------
However if I change the code for the collectionviewsource to:
  <CollectionViewSource x:Key="TreeAreaDS"
Source="TrashViewModel">
</CollectionViewSource>


I get this:
Locating source for 'c:\Builds\WPF_Scrum\Release_WPF_2010_Q2_SP2\Sources\Development\Core\Controls\Animation\AnimationManager.cs'. Checksum: MD5 {d5 92 43 67 7f ad 5a 42 93 7e b9 53 ee b2 ef 99}
The file 'c:\Builds\WPF_Scrum\Release_WPF_2010_Q2_SP2\Sources\Development\Core\Controls\Animation\AnimationManager.cs' does not exist.
Looking in script documents for 'c:\Builds\WPF_Scrum\Release_WPF_2010_Q2_SP2\Sources\Development\Core\Controls\Animation\AnimationManager.cs'...
Looking in the projects for 'c:\Builds\WPF_Scrum\Release_WPF_2010_Q2_SP2\Sources\Development\Core\Controls\Animation\AnimationManager.cs'.
The file was not found in a project.
Looking in directory 'C:\Program Files\Microsoft Visual Studio 10.0\VC\crt\src\'...
Looking in directory 'C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'...
Looking in directory 'C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'...
Looking in directory 'C:\Program Files\Microsoft Visual Studio 10.0\VC\atlmfc\include\'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: c:\Builds\WPF_Scrum\Release_WPF_2010_Q2_SP2\Sources\Development\Core\Controls\Animation\AnimationManager.cs.
The debugger could not locate the source file 'c:\Builds\WPF_Scrum\Release_WPF_2010_Q2_SP2\Sources\Development\Core\Controls\Animation\AnimationManager.cs'.

???
Any ideas?
I could try setting up a demo project, but I´d expose too much of the BL of the app and my employer wouldn´t like that..

1 Answer, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 07 Oct 2010, 03:56 PM
Hi Mariano,

I tested this but I was not able to reproduce this exception. Please find the attached project which I used to reproduce this issue based on the code you have provided. If possible, please modify it so that the issue becomes reproducible and send it back so that we can look into it.

All the best,
Alex Fidanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Mariano
Top achievements
Rank 1
Answers by
Alex Fidanov
Telerik team
Share this question
or