Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You did it almost right. The only problem is the binding to the selected item. Since the Source property of the frame is of type Uri, and has no dynamic converter, you need an own converter, which does the job:</p> <pre><code>public class UriConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { XmlElement element = value as XmlElement; if (element != null) { string uriSource = element.SelectSingleNode("source").InnerText; return new Uri(uriSource, UriKind.Relative); } else return null; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } </code></pre> <p>You now bind the selected item directly with no xpath and the converter extracts the uri string and builds an Uri object. Here is the fully working xaml (no code behind, except the converter):</p> <pre><code>&lt;Window x:Class="FrameTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:FrameTest" Title="MainWindow" Height="350" Width="525"&gt; &lt;Window.Resources&gt; &lt;DataTemplate x:Key="pageTemplate" &gt; &lt;StackPanel Orientation="Horizontal" &gt; &lt;TextBlock Text="{Binding XPath=name}" FontSize="14" VerticalAlignment="Center" Margin="4" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;XmlDataProvider x:Key="PagesData" XPath="Pages"&gt; &lt;x:XData&gt; &lt;Pages xmlns=""&gt; &lt;page id="page01"&gt; &lt;name&gt;Page 1&lt;/name&gt; &lt;source&gt;Pages/Page1.xaml&lt;/source&gt; &lt;/page&gt; &lt;page id="page02"&gt; &lt;name&gt;Page 2&lt;/name&gt; &lt;source&gt;Pages/Page2.xaml&lt;/source&gt; &lt;/page&gt; &lt;/Pages&gt; &lt;/x:XData&gt; &lt;/XmlDataProvider&gt; &lt;local:UriConverter x:Key="UriConverter" /&gt; &lt;/Window.Resources&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="200" /&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;ListBox x:Name="Nav_ListBox" Grid.Column="0" VerticalAlignment="Top" TextBlock.Foreground="Black" ItemTemplate="{DynamicResource pageTemplate}" ItemsSource="{Binding Source={StaticResource PagesData}, XPath=page}"/&gt; &lt;Frame NavigationUIVisibility="Hidden" JournalOwnership="OwnsJournal" Grid.Column="1" Source="{Binding ElementName=Nav_ListBox, Path=SelectedItem, Converter={StaticResource UriConverter}}"/&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>The pages have to be in the pages folder of the same directory of the window of course. In my example, I had two pages with a TextBlock "I am Page1/Page2".</p> <p>Hope i could help you :) </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload