NetAF.WPF 1.0.6

dotnet add package NetAF.WPF --version 1.0.6
                    
NuGet\Install-Package NetAF.WPF -Version 1.0.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetAF.WPF" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetAF.WPF" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="NetAF.WPF" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetAF.WPF --version 1.0.6
                    
#r "nuget: NetAF.WPF, 1.0.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetAF.WPF@1.0.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetAF.WPF&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=NetAF.WPF&version=1.0.6
                    
Install as a Cake Tool

NetAF.WPF

An extension library for NetAF targeting WPF and providing controls to allow NetAF to be easily integrated into WPF applications.

Getting Started

Running the Example

Getting started running NetAF in WPF is easy!

  • Clone the repo.
  • Build and run NetAF.WPF.TestApp.

How it Works

You need a couple of components to run a NetAF game:

  • Input - a way to interact with the game.
  • Output - a way to view the game.

Input

NetAF.WPF provides some easy ways to interact with the game:

Prompt

The prompt allows direct text entry. Add the prompt to a window or control:

<controls:NetAFPrompt/>

This will send input directly to the active game, in a window it looks like this:

<Window x:Class="NetAF.WPF.TestApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:controls="clr-namespace:NetAF.Targets.WPF.Controls;assembly=NetAF.WPF"
        mc:Ignorable="d"
        Title="Example" Height="850" Width="1000">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <controls:NetAFPrompt Grid.Row="1"/>
    </Grid>
</Window>
Command Buttons

Command buttons make it easier to interact with a game. There are a few main types:

  • NetAFCommandPicker - functions as a general command picker for all commands.
  • NetAFMovementCommandPicker - functions as a general command picker for movement commands.
  • NetAFRegionMapCommandPicker - functions as a general command picker for navigating the region map.

These can be used individually or as a combination. The ButtonLayout control provides a preconfigured control that combines all of the above controls.

<layouts:ButtonLayout x:Name="ButtonLayout"/>

Adding that to the window:

<Window x:Class="NetAF.WPF.TestApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:controls="clr-namespace:NetAF.Targets.WPF.Controls;assembly=NetAF.WPF"
        xmlns:inputLayouts="clr-namespace:NetAF.Targets.WPF.InputLayouts;assembly=NetAF.WPF"
        mc:Ignorable="d"
        Title="Example" Height="850" Width="1000">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <controls:NetAFPrompt Grid.Row="1"/>
        <inputLayouts:ButtonLayout Grid.Row="2"/>
    </Grid>
</Window>

Output

NetAF provides a options for viewing the game:

Text Terminal

A basic terminal that just displays text without any styling.

<controls:NetAFMTextTerminal/>

Adding that to the window:

<Window x:Class="NetAF.WPF.TestApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:controls="clr-namespace:NetAF.Targets.WPF.Controls;assembly=NetAF.WPF"
        xmlns:inputLayouts="clr-namespace:NetAF.Targets.WPF.InputLayouts;assembly=NetAF.WPF"
        mc:Ignorable="d"
        Title="Example" Height="850" Width="1000">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <controls:NetAFTextTerminal x:Name="Terminal" Grid.Row="0"/>
        <controls:NetAFPrompt Grid.Row="1"/>
        <inputLayouts:ButtonLayout Grid.Row="2"/>
    </Grid>
</Window>
Markup Terminal

The markup terminal is highly recommended as it provides customisable styling to frames.

<controls:NetAFMarkupTerminal/>

Adding that to the window:

<Window x:Class="NetAF.WPF.TestApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:controls="clr-namespace:NetAF.Targets.WPF.Controls;assembly=NetAF.WPF"
        xmlns:inputLayouts="clr-namespace:NetAF.Targets.WPF.InputLayouts;assembly=NetAF.WPF"
        mc:Ignorable="d"
        Title="Example" Height="850" Width="1000">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <controls:NetAFMarkupTerminal x:Name="Terminal" Grid.Row="0"/>
        <controls:NetAFPrompt Grid.Row="1"/>
        <inputLayouts:ButtonLayout Grid.Row="2"/>
    </Grid>
</Window>
Directing Game Output to the Terminal

The game output needs to be pointed to the terminal. This is done with adapters. In the case of a NetAFTextTerminal the terminal is passed directly to the adapter on configuration:

using NetAF.Logic;
using NetAF.Rendering.FrameBuilders;
using NetAF.Targets.Text;
using System.Windows;

namespace NetAF.WPF.TestApp
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            var configuration = new GameConfiguration(new TextAdapter(Terminal), FrameBuilderCollections.Text, Assets.Size.Dynamic);
            GameExecutor.Execute(ExampleGame.Create(configuration));
        }
    }
}

And in the case that markup is used:

using NetAF.Logic;
using NetAF.Rendering.FrameBuilders;
using NetAF.Targets.Markup;
using System.Windows;

namespace NetAF.WPF.TestApp
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            var configuration = new GameConfiguration(new MarkupAdapter(Terminal), FrameBuilderCollections.Markup, Assets.Size.Dynamic);
            GameExecutor.Execute(ExampleGame.Create(configuration));
        }
    }
}

With that you should be ready to go!

Persistence

The NetAFFileManager control adds easy persistence options to a game:

<controls:NetAFFileManager/>

No configuration is required.

Styling

The controls can all be styled. By default a dark style is included - Targets/WPF/Styles/Dark.xaml.

To use this style merge it with the resource dictionary of your window or control:

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/NetAF.WPF;component/Targets/WPF/Styles/Dark.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>

And then apply the styles to the various controls:

<controls:NetAFMarkupTerminal Style="{StaticResource DarkMarkupTerminalStyle}"/>
<controls:NetAFPrompt Style="{StaticResource DarkPromptStyle}"/>
<layouts:ButtonLayout Style="{StaticResource DarkButtonLayoutStyle}"/>

Example Game

The ExampleGame is included in the repo.

Documentation

Please visit https://benpollarduk.github.io/NetAF-docs/ to view the NetAF documentation.

For Open Questions

Visit https://github.com/benpollarduk/NetAF.WPF/issues

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 93 2/19/2026
1.0.5 91 2/17/2026
1.0.4 134 2/14/2026
1.0.3 85 2/13/2026
1.0.2 116 2/13/2026
1.0.1 91 2/13/2026
1.0.0 85 2/13/2026
0.0.3 87 2/12/2026

Minor optimisation, updated NetAF.