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

Frame navigation through with treview menu on selected item?

7 Answers 289 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Vlad
Top achievements
Rank 1
Vlad asked on 02 Nov 2010, 04:32 AM

I was not able to find any sample. I am wondering if there is any good sample. I want to be able to update frame.source based on selected items of the treeview. I generate all content with XMLDataprovider. Thank you in advance!

XAML:

 

<Window
    mc:Ignorable="d"
    x:Class="TwoListboxes_2.MainWindow"
    xmlns:local="clr-namespace:TwoListboxes_2"
    Title="MainWindow"
    Width="1000" Height="700">
    <Window.Resources>
        <local:UriConverter x:Key="UriConverter" /> 
        <XmlDataProvider x:Key="PageData" XPath="/Pages" Source="Data/data.xml" />
          
        <HierarchicalDataTemplate 
            DataType="Page" 
            ItemsSource="{Binding XPath=Level2}">
            <TextBlock FontWeight="Bold" Text="{Binding XPath=@Name}" />
        </HierarchicalDataTemplate>
  
        <HierarchicalDataTemplate 
            DataType="Level2" 
            ItemsSource="{Binding XPath=Level3}">
            <TextBlock Foreground="Red" Text="{Binding XPath=@Name}" />
        </HierarchicalDataTemplate>
  
        <DataTemplate 
            DataType="Level3">
            <TextBlock FontStyle="Italic" Text="{Binding XPath=@Name}" />
        </DataTemplate>
    </Window.Resources>
    <Grid HorizontalAlignment="Left" VerticalAlignment="Top">   
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="215"/>
                <ColumnDefinition Width="1"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid >
                <Border HorizontalAlignment="Left">
                    <telerik:RadTreeView 
                        x:Name="Nav_ListBox" 
                        ItemsSource="{Binding Source={StaticResource PageData}, XPath=Page}" 
                        SelectedValuePath="@UriSource" />
                </Border>
            </Grid
            <Frame Grid.Column="2" x:Name="ContentFrame" JournalOwnership="OwnsJournal" NavigationUIVisibility="Visible" Width="Auto" 
                Source="{Binding SelectedValuePath, Converter={StaticResourXML:ce UriConverter}, ElementName=Nav_ListBox, Mode=TwoWay}" />
    </Grid
</Window>

XML:

<?xml version="1.0" encoding="UTF-8"?>
<Pages>
    <Page Name="Name 1" UriSource="Pages/Name1.xaml" />
    <Page Name="Name 2" UriSource="Pages/Name2.xaml">   
        <Level2 Name="ALL1" UriSource="Pages/All1.xaml" />
        <Level2 Name="ALL2" UriSource="Pages/All2.xaml" />
        <Level2 Name="ALL3" UriSource="Pages/All3.xaml" />
    </Page>
    <Page Name="Name 3" UriSource="Pages/Name3.xaml">
        <Level2 Name="ALL4" UriSource="Pages/All1.xaml" >
            <Level3 Name="ALL3_1" UriSource="Pages/All1.xaml" />
            <Level3 Name="ALL3_2" UriSource="Pages/All2.xaml" />
            <Level3 Name="ALL3_3" UriSource="Pages/All3.xaml" />
        </Level2>
        <Level2 Name="ALL5" UriSource="Pages/All2.xaml" />
        <Level2 Name="ALL6" UriSource="Pages/All3.xaml" />
    </Page
    <Page Name="Name 4" UriSource="Pages/Name4.xaml" />
</Pages>


 

7 Answers, 1 is accepted

Sort by
0
Vlad
Top achievements
Rank 1
answered on 04 Nov 2010, 03:10 AM
I am still looking for the solution. It will be nice if someone will help. Thank you in advance.
0
Accepted
Viktor Tsvetkov
Telerik team
answered on 04 Nov 2010, 05:07 PM
Hi Vlad,

Could you please examine the attached sample project and if you have further questions feel free to ask?

Best wishes,
Viktor Tsvetkov
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
0
Vlad
Top achievements
Rank 1
answered on 05 Nov 2010, 10:57 PM
Thank you a lot! It works great. I just found out that it does not change a selected state of a treeview item while navigation happens with Back/Forward button of the Frame. There is no indication of which treeview item associated with the content loaded into frame. I am wondering if it is possible to achieve. Thank you again.
0
Viktor Tsvetkov
Telerik team
answered on 08 Nov 2010, 10:07 AM
Hi Vlad,

Attached is the modified project, examine it and do not hesitate to ask if you still have some qustions.

All the best,
Viktor Tsvetkov
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
0
Vlad
Top achievements
Rank 1
answered on 09 Nov 2010, 06:16 AM
It is super great. Thank you a lot for your time and help! I am only wondering what 'Substring(37)' from the converter is reffering to?

string

 

 

uriSource = value.ToString().Substring(37);

Best!

 


0
Accepted
Viktor Tsvetkov
Telerik team
answered on 09 Nov 2010, 10:57 AM
Hello Vlad,

This is the substring with the UriSource attribute from the xml file, because in the ConvertBack method the value that comes is the whole path to the UserControl. You can add a breakpoint and see what happens.

Regards,
Viktor Tsvetkov
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
0
Vlad
Top achievements
Rank 1
answered on 09 Nov 2010, 04:49 PM
It is an interesting approach. Thank you!
Tags
TreeView
Asked by
Vlad
Top achievements
Rank 1
Answers by
Vlad
Top achievements
Rank 1
Viktor Tsvetkov
Telerik team
Share this question
or