Frame navigation through with treview menu on selected item?

8 posts, 2 answers
  1. Vlad
    Vlad avatar
    19 posts
    Member since:
    Nov 2010

    Posted 01 Nov 2010 Link to this post

    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>


     

  2. Vlad
    Vlad avatar
    19 posts
    Member since:
    Nov 2010

    Posted 03 Nov 2010 Link to this post

    I am still looking for the solution. It will be nice if someone will help. Thank you in advance.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 04 Nov 2010 Link to this post

    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
  5. Vlad
    Vlad avatar
    19 posts
    Member since:
    Nov 2010

    Posted 05 Nov 2010 Link to this post

    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.
  6. Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 08 Nov 2010 Link to this post

    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
  7. Vlad
    Vlad avatar
    19 posts
    Member since:
    Nov 2010

    Posted 09 Nov 2010 Link to this post

    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!

     


  8. Answer
    Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 09 Nov 2010 Link to this post

    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
  9. Vlad
    Vlad avatar
    19 posts
    Member since:
    Nov 2010

    Posted 09 Nov 2010 Link to this post

    It is an interesting approach. Thank you!
Back to Top
UI for WPF is Visual Studio 2017 Ready