| Crates.io | winrt-xaml |
| lib.rs | winrt-xaml |
| version | 1.0.0 |
| created_at | 2025-12-31 19:33:53.869066+00 |
| updated_at | 2025-12-31 19:33:53.869066+00 |
| description | A Rust library for creating modern Windows UIs using WinRT and XAML with reactive data binding |
| homepage | https://github.com/pegasusheavy/winrt-xaml |
| repository | https://github.com/pegasusheavy/winrt-xaml |
| max_upload_size | |
| id | 2015181 |
| size | 1,400,788 |
A modern Rust library for creating beautiful Windows UIs using WinRT/XAML Islands
WinRT-XAML provides native WinRT/XAML rendering in Rust applications! ๐
View Status โ | Architecture โ | Build Guide โ
# Try the scrollable list demo
cargo run --example scrollable_list
# Try the functional calculator
cargo run --example winrt_calculator_functional
Add to your Cargo.toml:
[dependencies]
winrt-xaml = "0.1.0"
# Scrollable list with 30 items
cargo run --example scrollable_list
# Functional calculator
cargo run --example winrt_calculator_functional
# Chat interface
cargo run --example chat_interface
# Interactive counter
cargo run --example counter
use winrt_xaml::error::Result;
use winrt_xaml::xaml_native::*;
use windows::Win32::System::Com::{CoInitializeEx, COINIT_APARTMENTTHREADED};
fn main() -> Result<()> {
// Initialize COM for WinRT
unsafe {
CoInitializeEx(None, COINIT_APARTMENTTHREADED).ok()?;
}
// Initialize XAML
let _xaml_manager = XamlManager::new()?;
// Create host window
let hwnd = create_host_window("My App", 600, 400)?;
// Create XAML source and attach
let mut xaml_source = XamlSource::new()?;
let island_hwnd = xaml_source.attach_to_window(hwnd)?;
// Create UI
let panel = XamlStackPanel::new()?;
panel.set_vertical(true)?;
panel.set_spacing(20.0)?;
panel.set_background(0xFF1A1A1A)?; // Dark theme
panel.set_padding(30.0, 30.0, 30.0, 30.0)?;
let button = XamlButton::new()?;
button.set_content("Click Me!")?;
button.set_size(150.0, 50.0)?;
button.set_background(0xFF0078D4)?; // Microsoft blue
button.on_click(|| println!("Button clicked!"))?;
panel.add_child(&button.as_uielement())?;
xaml_source.set_content_element(&panel.as_uielement())?;
// Show and run
unsafe {
ShowWindow(island_hwnd, SW_SHOW);
ShowWindow(hwnd, SW_SHOW);
}
// Message loop...
Ok(())
}
See examples/ for complete, working examples.
See the examples/ directory for 15 comprehensive examples:
scrollable_list.rs - โจ ScrollViewer with 30 items, color-coded badgeswinrt_calculator_functional.rs - โจ Fully functional calculator with eventschat_interface.rs - โจ Chat UI with text input/outputwinrt_controls_demo.rs - Showcase of all controlswinrt_counter.rs - Interactive counter with statecounter.rs - Counter with 4 operations (inc/dec/reset/double)counter_simple.rs - Minimal counter exampletodo_app.rs - Todo list with add/clear functionalityform_demo.rs - Multi-field registration formsettings_panel.rs - Settings UI with theme togglescolor_picker.rs - Color selection interfacecalculator.rs - Calculator UI (non-interactive)basic_window.rs - Simple click countersimple_window.rs - Hello World with stylingcontrols_demo.rs - Basic controls showcaseAll examples feature modern dark themes with Fluent Design styling!
# Run any example
cargo run --example scrollable_list
cargo run --example winrt_calculator_functional
cargo run --example chat_interface
WinRT-XAML provides minimal FFI overhead with zero-cost abstractions:
| Operation | Performance | Notes |
|---|---|---|
| FFI Function Call | ~5-10ns | Negligible overhead |
| String Conversion | ~100ns | UTF-8 to UTF-16 |
| Object Creation | ~1-5ฮผs | COM allocation |
| Event Dispatch | ~50-100ns | Callback invocation |
Key Performance Features:
Complete Build Process (first time):
# 1. Build C++ helper DLL
cd xaml_islands_helper
mkdir build
cd build
cmake ..
cmake --build . --config Debug
cd ../..
# 2. Build Rust library and examples
cargo build --all-targets
# 3. Run an example
cargo run --example scrollable_list
Incremental Builds (after initial setup):
# Just rebuild Rust (C++ DLL already built)
cargo build --all-targets
# Rebuild specific example
cargo build --example chat_interface
See BUILD_SYSTEM.md for comprehensive build documentation.
# Run tests (when implemented)
cargo test --lib
# Test by running examples
cargo run --example scrollable_list
We welcome contributions! Please see CONTRIBUTING.md for details.
Fork the repository
Create a feature branch (git checkout -b feature/amazing-feature)
Make your changes
Run tests and benchmarks
Commit your changes (git commit -m 'Add amazing feature')
Push to the branch (git push origin feature/amazing-feature)
Open a Pull Request
For security concerns, please see SECURITY.md.
Licensed under either of:
at your option.
Support this project:
Status: โ Production-Ready Core | Version: 0.1.0 | Rust: 1.70+ | Windows: 10/11
๐ฏ Examples โ | ๐ Status โ | ๐๏ธ Architecture โ | ๐จ Build โ