Skip to content

Updated: 30/11/2026

WPF in the browser

A desktop (window) application is one of the typical practical parts of the Polish INF.04 exam, and in C# it usually means WPF: the window layout in XAML and event handling in C#. In class that normally requires Visual Studio, which has to be installed and runs only on Windows. In BitWizards the whole project lives in a browser tab: MainWindow.xaml with an editor like the one in Visual Studio, the code-behind in MainWindow.xaml.cs, and an app window that runs as soon as you click Run.

Course: WPF desktop apps step by step - first lesson (lessons are in Polish)

XAML editor: Code, Split and Design

  • Code - the XAML file with syntax highlighting and warnings with line numbers,
  • Design - a window preview, a toolbox (Button, Label, TextBox, TextBlock, PasswordBox, CheckBox, RadioButton, ComboBox, ListBox, DataGrid, Slider, ProgressBar, Menu, MenuItem, Image, shapes and panels) and a panel with the selected control’s properties and events,
  • Split - design and code together: clicking a control in the preview selects it in the code.

Every change in the designer is a plain text edit of the XAML, so formatting stays intact and Undo covers code and design together. The layout is computed by Grid (rows, columns, Auto, *, ColumnSpan), StackPanel, WrapPanel, DockPanel, Canvas, Border and GroupBox, with margins and alignment as in WPF.

Code-behind in C#

MainWindow.xaml.cs is a real partial window class: a constructor with InitializeComponent(), fields from x:Name, event handlers (Click, TextChanged, Checked, SelectionChanged, ValueChanged), MessageBox.Show with a Yes/No question, list Items.Add, Visibility, IsEnabled, colours and Close(). On top of that, DispatcherTimer (clocks, stopwatches, countdowns) and a DataGrid with ItemsSource: columns with Binding and StringFormat or generated automatically, an ObservableCollection that refreshes the table, and the selected row as SelectedItem. As in WPF, a List<T> needs Items.Refresh().

A window can have a menu (Menu and MenuItem with submenus, separators, an access key _File, a shortcut shown by InputGestureText and IsCheckable items), and a project can have more windows: Window1.xaml and Window1.xaml.cs next to the main one, Show() for a modeless window and ShowDialog() with DialogResult, IsDefault and IsCancel for a dialog that blocks the main window until it closes.

Images are project files, like ones added in Visual Studio with the Resource build action: tabs next to the code files, an Image control with Source="slonce.png" or a folder path (Images/jablko.png, also pack://application:,,,/ addresses), Stretch (Uniform, Fill, UniformToFill, None), changing the picture in code with new BitmapImage(new Uri(...)) and clicking an image (MouseLeftButtonDown, MouseDown). The editor warns about an image that is not in the project.

Data binding works as in WPF: a DataContext set in code or in <Window.DataContext> (a class with the local: prefix), {Binding Name} on control properties (Text, Content, IsChecked, Value, ItemsSource, SelectedItem, IsEnabled, Visibility), ElementName to another control, StringFormat, Mode, UpdateSourceTrigger, FallbackValue, converters (IValueConverter, BooleanToVisibilityConverter) and SetBinding in code. A model with INotifyPropertyChanged refreshes the window itself, a text box passes its value on losing focus or on every letter, and text that cannot become a number gets a red border. Binding errors go to the output panel like the Visual Studio Output window.

Commands (ICommand) connect buttons and menu items to the view model: Command="{Binding SaveCommand}" and CommandParameter on Button and MenuItem, CanExecute disables the control by itself, and CanExecuteChanged and CommandManager.RequerySuggested (WPF asks commands again after every click and typed character) bring it back. The student writes their own RelayCommand class, as in MVVM projects.

Tabs (TabControl with TabItem) split a long form or settings: Header, selection through SelectedIndex, SelectedItem and IsSelected, the SelectionChanged event and headers on the side or at the bottom (TabStripPlacement). Controls on hidden tabs exist as in WPF, so code reads fields from every tab. Design mode and the palette add tabs to a TabControl.

Dates: DatePicker (a field with a drop-down calendar, the date can also be typed) and Calendar (a whole month) with SelectedDate, DisplayDate, a range DisplayDateStart/DisplayDateEnd, BlackoutDates (in XAML and in code) and the SelectedDateChanged and SelectedDatesChanged events. Dates are formatted as on Polish Windows: Text gives 24.12.2026, and SelectedDateFormat="Long" gives 24 grudnia 2026. Selecting a blacked-out day in code throws an exception as in WPF.

Lists and trees: ListView with a GridView (GridViewColumn with Header, Width and DisplayMemberBinding, items from ItemsSource or Items, selection) and TreeView with nested TreeViewItem (Header, IsExpanded, IsSelected, SelectedItemChanged, Expanded/Collapsed). A tree built in code (Items.Add(new TreeViewItem { ... })) shows up in the window right away, and an item’s Parent leads to the item above.

Window extras: a toolbar (ToolBarTray with ToolBar and flat buttons), a status bar (StatusBar with StatusBarItem), a collapsible Expander (IsExpanded, Expanded/Collapsed), formatted text in a TextBlock (Run, Bold, Italic, Underline, LineBreak, Hyperlink with Click and RequestNavigate; a named Run changes from code, Inlines.Add adds elements) and a simple RichTextBox (FlowDocument with Paragraph blocks, text through TextRange, Document.Blocks, AppendText).

Drawing on a Canvas: the shapes Line, Polyline, Polygon, Path (a path made of the M, L, H, V, C, A, Z commands), Rectangle with RadiusX/RadiusY and Ellipse with Fill, Stroke, StrokeThickness and StrokeDashArray. From code you can use Points.Add, change Fill, call Canvas.SetLeft/SetTop and create shapes in code (Children.Add, Children.Clear), so a chart from data or a game board shows up in the window right away. A click on the canvas gives e.GetPosition.

Controls created in code: new Button { ... }, new TextBox(), new StackPanel() added with Children.Add, Insert, Remove and Clear, or set as Content or Border.Child. Events of such controls (Click += ..., TextChanged) work like those of controls from XAML, so buttons generated in a loop, a form built from a list of fields, a list with a Remove button and a game board work in the window right away. An element that already has a parent throws an exception, as in WPF.

Files: File.WriteAllText, ReadAllText, ReadAllLines, WriteAllLines, AppendAllText, Exists and Delete, StreamReader and StreamWriter, and the OpenFileDialog and SaveFileDialog windows with a filter (Filter, DefaultExt, FileName, SafeFileName). The program works on files in the project folder kept in browser memory: files prepared by the teacher (e.g. grades.csv) and files it saves itself. The file window lists files matching the filter, and the program’s files with their content are shown under the app window.

Async and animation: async void event handlers with await Task.Delay (the window does not freeze: countdowns, a message after a delay), await Task.Run, Dispatcher.Invoke and BeginInvoke. DoubleAnimation and ColorAnimation from code (BeginAnimation on Opacity, Width, Height and a brush colour, Completed, AutoReverse, RepeatBehavior, EasingFunction) and a Storyboard in XAML started by an EventTrigger (Loaded, Button.Click) and stopped with StopStoryboard. Frozen Brushes.Red throw as in WPF. Tasks check timing on a virtual clock, so a 5-second countdown takes a moment.

Resources and styles keep the common look in one place: <Window.Resources> (also panel resources) with brushes, strings and numbers (sys:String, sys:Double), {StaticResource} and {DynamicResource} (replacing a resource in code refreshes the controls, e.g. a dark theme), Style with Setter, a default style for a type (no x:Key), BasedOn and Trigger on IsMouseOver, IsPressed, IsFocused, IsEnabled and IsChecked. A value set on the control wins over the style as in WPF, Design mode shows controls with their style, and FindResource and a Style set in code work in the program. The code is compiled by the real C# compiler (Roslyn) in the browser, the same as in the C# course, so errors carry Visual Studio codes (e.g. CS0103). Console.WriteLine goes to a panel under the window, handy for debugging.

Checking like a user

A window-app task has two parts:

  • XAML controls - type, x:Name and properties, optionally in a given order,
  • scenarios - steps on the running app: type, click, tick, select, slide, click a menu item (File/Save) or an image, answer a MessageBox, pick a file in the Open/Save window, work in a dialog or close it, wait (timers tick on the checker’s clock, so a scenario takes a fraction of a second), then expect a label, a list item or table row count, a DataGrid cell, visibility, enabled or checked state, the image shown, an open window, a message text, the content of a saved file or a closed window.

Checking runs after every Run, and each scenario starts a fresh window.

Limitations

To be honest about what is missing: templates (ControlTemplate, DataTemplate), data triggers (DataTrigger), EventTrigger other than Loaded and Click, separate resource dictionaries and App.xaml, built-in commands (ApplicationCommands, RoutedCommand) and KeyBinding shortcuts, editing DataGrid cells, context menus and keyboard shortcuts (InputGestureText is only displayed), access to files on the computer’s disk (the program sees only the project folder, without subfolders), the overwrite confirmation window, and images from the internet. Windows Forms is not supported.

INF.04 exam - C# - Android - .NET MAUI

Frequently asked questions

Do I need to install Visual Studio?

No. MainWindow.xaml, MainWindow.xaml.cs and the running app window are all in a browser tab, also on low-end school computers and on systems other than Windows. Course lessons open without signing in; with an account, work is saved automatically.

Is it real C#?

Yes. The code-behind is compiled by the real C# compiler (Roslyn) and runs on .NET 10, both in the browser, just like in the C# Basics course. The WPF window itself is a stand-in: the browser draws the XAML, and the controls (Button, TextBox, ListBox, MessageBox...) have the same names, properties and events as in WPF.

How are tasks checked?

A task checks the controls in the XAML (type, x:Name, properties) and clicks through the running app: it types text, clicks buttons and menu items, ticks boxes, picks list items, moves sliders, answers MessageBox dialogs and works in dialog windows, then compares labels, item counts, visibility and messages. Each scenario starts from a fresh window.

Does it replace Visual Studio in the exam?

No. In the exam you work in the environment provided at your workstation. BitWizards teaches the same project layout (MainWindow.xaml and MainWindow.xaml.cs, namespace WpfApp) and the same classes, so moving to Visual Studio is mostly a different window, not a different way of thinking.

Start now

BitWizards is free. Try the demo without signing in, or sign in to the app to save your progress.

See how to get started