Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I cant exactly understand why your frame cant be referenced. Did you try another name? I would like you to suggest another smarter way to do this. You can use a Binding for the source. Here is a little example:</p> <pre><code>&lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="24"/&gt; &lt;RowDefinition Height="*" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;ComboBox x:Name="SourceBox" Grid.Row="0" VerticalAlignment="Top" DisplayMemberPath="Label" TextBlock.Foreground="Black"&gt;&lt;/ComboBox&gt; &lt;Frame NavigationUIVisibility="Hidden" JournalOwnership="OwnsJournal" Grid.Row="1" Source="{Binding ElementName=SourceBox, Path=SelectedItem.Source}"/&gt; &lt;/Grid&gt; </code></pre> <p>Notice the Source binding on the frame. There is also no more x:Name on the Frame.</p> <p>In the code behind you have to build a propper ItemSource for the combobox. Therefore i built a simple object, which holds a lable and a source.</p> <pre><code>public class SourceHolder { public string Label { get; set; } public Uri Source { get; set; } } </code></pre> <p>In the constructor of your window you can assign the itemssource to your combobox:</p> <pre><code>public Window1() { List&lt;SourceHolder&gt; sources = new List&lt;SourceHolder&gt;(); sources.Add(new SourceHolder() { Label = "Page1", Source = new Uri("Page1.xaml", UriKind.Relative) } ); sources.Add(new SourceHolder() { Label = "Page2", Source = new Uri("Page2.xaml", UriKind.Relative) } ); InitializeComponent(); this.SourceBox.ItemsSource = sources; } </code></pre> <p>The result is, that the combobox has two items (Page1, Page2). If you change the item, the frame updates it's content with the given Source of the selected combobox item.</p> <p>Jan</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. This table or related slice is empty.
    1. 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