Apply theme to custom stackpanel?

Themes, Shared, and Core Libraries for Avalonia Forum

Posted 3 days ago by Jacob Green
Version: 25.2.1
Avatar

I was making control wrappers around avalonia and actipro themes due to me disliking lookless controls

How would I apply the current actipro theme to my stackpanel control in a way that it respects the border, background and the shade of the palette?

This is what I have so far..

<ContentControl xmlns="https://github.com/avaloniaui"
                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:v="using:AvaloniaMario.Views"
                xmlns:vm="using:AvaloniaMario.ViewModels"
                xmlns:actipro="http://schemas.actiprosoftware.com/avaloniaui"
                mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
                x:Class="AvaloniaMario.Views.StackPanel"
                x:DataType="v:StackPanel">
    
    <ControlTheme x:Key="{x:Type v:StackPanel}" TargetType="v:StackPanel">
        <Setter Property="Template">
            <ControlTemplate>
                <Border>
                    <StackPanel Orientation="{TemplateBinding Orientation}">
                        <ContentPresenter Name="PART_ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}"/>
                    </StackPanel>
                </Border>
            </ControlTemplate>
        </Setter>
    </ControlTheme>
</ContentControl>

Comments (1)

Posted 2 days ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Jacob,

Check out our Themes' "Containers" QuickStart in our samples project. It shows all of the various container-related brushes that can be used from our themes for a consistent look.

Here's a link to the source of that sample. Please run the sample project to see it in action.


Actipro Software Support

Add Comment

Please log in to a validated account to post comments.