# Try live XAML

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/start/playground/

Edit the markup and see actual FerroUI controls update. The example runtime loads only after you press **Run example**. The playground interprets XAML in the browser with a precompiled runtime; it cannot compile Rust, so declarative Rust views (builders, `rsx!`, components) run from the repository's samples instead: `cargo run -p hello-world-hooks`, `cargo run -p view-gallery`, or `cargo run -p todo-mvc`. The controls you see here are the same ones a component creates.

### Buttons and commands

```xml
<StackPanel xmlns="https://github.com/ferroui" Spacing="12">
  <TextBlock Text="A clear next step" FontSize="20" />
  <Button Content="Continue" HorizontalAlignment="Left" />
  <Button Content="Unavailable" IsEnabled="False" />
</StackPanel>
```

```rust
use ferroui::prelude::*;
use ferroui::base::metadata::from_markup_value;
use ferroui::markup_xaml_loader::FerroRuntimeXamlLoader;

#[repr(C)]
pub struct App {
    base: Application,
}

ferro_class!(App: Application);
ferro_impl_classes!(App: FerroObjectImpl);

impl NewApplication for App {
    fn new_application() -> Ref<Self> {
        instantiate(Self { base: Application::construct() })
    }
}

impl ApplicationImpl for App {
    fn initialize(this: &Self) {
        Self::parent_initialize(this);
        ferroui::controls::register_types();
        FerroRuntimeXamlLoader::register();
        this.styles().add(FluentTheme::new().as_style());
    }

    fn on_framework_initialization_completed(this: &Self) {
        let lifetime = this.application_lifetime();
        if let Some(desktop) = lifetime.as_ref().and_then(|l| l.as_classic_desktop_style_application_lifetime()) {
            let value = FerroRuntimeXamlLoader::load(include_str!("View.xaml"), None, None, None, false)
                .expect("Example XAML should load");
            let view = from_markup_value::<Ref<Control>>(&Some(value)).expect("Example root must be a control");
            let window = Window::new();
            window.set_title(Some("FerroUI documentation example".to_owned()));
            window.set_width(560.0);
            window.set_height(420.0);
            window.set_padding(Thickness::uniform(24.0));
            window.set_content(Some(Control::boxed(view)));
            desktop.set_main_window(Some(window));
        }
        Self::parent_on_framework_initialization_completed(this);
    }
}

fn main() -> std::process::ExitCode {
    let args: Vec<String> = std::env::args().skip(1).collect();
    let result = AppBuilder::configure::<App>().use_platform_detect().start_with_classic_desktop_lifetime(&args);
    std::process::ExitCode::from(result as u8)
}

```

[Download the complete desktop project](/docs/0.5.0/generated/examples/button.zip). The browser preview runs real FerroUI controls with precompiled Rust support; this desktop application loads the same XAML.


## Explore layout

Try changing the column definitions or preview width. Invalid markup leaves the last successful view in place.

### A responsive form

```xml
<Grid xmlns="https://github.com/ferroui" ColumnDefinitions="Auto,*" RowDefinitions="Auto,Auto" Margin="12">
  <TextBlock Text="Name" Margin="0,0,16,12" />
  <TextBox Grid.Column="1" PlaceholderText="Your name" />
  <TextBlock Grid.Row="1" Text="Team" Margin="0,0,16,0" />
  <TextBox Grid.Row="1" Grid.Column="1" PlaceholderText="Your team" />
</Grid>
```

```rust
use ferroui::prelude::*;
use ferroui::base::metadata::from_markup_value;
use ferroui::markup_xaml_loader::FerroRuntimeXamlLoader;

#[repr(C)]
pub struct App {
    base: Application,
}

ferro_class!(App: Application);
ferro_impl_classes!(App: FerroObjectImpl);

impl NewApplication for App {
    fn new_application() -> Ref<Self> {
        instantiate(Self { base: Application::construct() })
    }
}

impl ApplicationImpl for App {
    fn initialize(this: &Self) {
        Self::parent_initialize(this);
        ferroui::controls::register_types();
        FerroRuntimeXamlLoader::register();
        this.styles().add(FluentTheme::new().as_style());
    }

    fn on_framework_initialization_completed(this: &Self) {
        let lifetime = this.application_lifetime();
        if let Some(desktop) = lifetime.as_ref().and_then(|l| l.as_classic_desktop_style_application_lifetime()) {
            let value = FerroRuntimeXamlLoader::load(include_str!("View.xaml"), None, None, None, false)
                .expect("Example XAML should load");
            let view = from_markup_value::<Ref<Control>>(&Some(value)).expect("Example root must be a control");
            let window = Window::new();
            window.set_title(Some("FerroUI documentation example".to_owned()));
            window.set_width(560.0);
            window.set_height(420.0);
            window.set_padding(Thickness::uniform(24.0));
            window.set_content(Some(Control::boxed(view)));
            desktop.set_main_window(Some(window));
        }
        Self::parent_on_framework_initialization_completed(this);
    }
}

fn main() -> std::process::ExitCode {
    let args: Vec<String> = std::env::args().skip(1).collect();
    let result = AppBuilder::configure::<App>().use_platform_detect().start_with_classic_desktop_lifetime(&args);
    std::process::ExitCode::from(result as u8)
}

```

[Download the complete desktop project](/docs/0.5.0/generated/examples/grid.zip). The browser preview runs real FerroUI controls with precompiled Rust support; this desktop application loads the same XAML.


The local playground deliberately supports a limited registered vocabulary and bundled resources. Use the complete application samples for native services and custom code.

## Try a small change and check the result

1. Run the button example, then change `Content` to “Save changes” and run it again.
2. Set `IsEnabled="False"` and confirm the control no longer activates.
3. In the Grid example, switch between `Auto,*` and `*,*` columns and narrow the preview.
4. Introduce an unknown property to inspect its error, then reset the example.

This runner supplies a theme and supported type registration. A model binding such as `{Binding SaveCommand}` still needs an application model; typing it here does not create one. Follow the [commands guide](/docs/0.5.0/guides/commands/) for that integration.

## Public APIs and controls

- [Button](/docs/0.5.0/controls/reference/button/) — content, enabled state, commands, and events.
- [Grid](/docs/0.5.0/controls/reference/grid/) — columns, rows, and attached layout properties.
- [XAML syntax](/docs/0.5.0/xaml/overview/) and [layout](/docs/0.5.0/design/layout/) explain the edits; [builders, rsx! & signals](/docs/0.5.0/declarative/overview/) writes the same views in Rust.
