Skip to content
Discussion options

You must be logged in to vote

This is already possible. Most (any?) types you define in an Avalonia project can have a XAML file if you simply create a matching .xaml file with a matching x:Class though it's rarely useful.

MyDataTemplate.axaml.cs

using Avalonia.Markup.Xaml.Templates;

namespace AvaloniaSandbox.Shell;
public class MyDataTemplate : DataTemplate { }

MyDataTemplate.axaml

<DataTemplate
    x:Class="AvaloniaSandbox.Shell.MyDataTemplate"
    x:DataType="vm:MainWindowViewModel"
    xmlns="https://github.com/avaloniaui"
    xmlns:vm="using:AvaloniaSandbox.ViewModels"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <TextBlock Text="{Binding Text}" />
</DataTemplate>

Usage :

<ContentControl Content=

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jyswjjgdwtdtj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants