Loading the navigation demo…

WPF navigation on Bevy: three XAML Pages in a Frame, ◀ ▶ journal chrome, Hyperlinks that navigate pages (external links still open the browser), and a counter that survives page re-creation because state lives in the DataContext.

How it's built

From examples/navigation.rs — WPF Frame/Page navigation on Bevy.

1. Register pages as routes

Compile-time validated scenes, registered like web routes (wasm-safe).

app.register_page("home.xaml", xaml!(r##"<Page Title="Home">
      <StackPanel Margin="24">
        <TextBlock Text="{Binding count}" FontWeight="Bold"/>
        <Hyperlink NavigateUri="settings.xaml">Open Settings</Hyperlink>
      </StackPanel>
    </Page>"##))
2. Host them in a Frame

Source= navigates on startup; the built-in chrome drives the journal.

<DockPanel>
  <StatusBar DockPanel.Dock="Bottom"> ... </StatusBar>
  <Frame Source="home.xaml"/>
</DockPanel>
3. React to navigation

Pages re-instantiate on every visit (WPF KeepAlive=False); a PfNavigated message lets you wire fresh buttons. State survives in the DataContext.

fn wire_new_pages(mut navigated: MessageReader<PfNavigated>, ui: PfQuery, mut commands: Commands) {
    for nav in navigated.read() {
        if nav.source == "settings.xaml"
            && let Some(bump) = ui.by_name("Bump") {
            commands.entity(bump).observe(|_: On<Pointer<Click>>, vm: Res<VmHandle>| {
                vm.0.update(|m: &mut Vm| m.count += 1);
            });
        }
    }
}