Collection of controls for WinUI 2, WinUI 3, and Uno Platform developers. Simplifies and demonstrates common developer tasks building experiences for Windows with .NET.
Adding a GridSplitter in C# will not let it render. Adding it in XAML though will let it render.
Also: When added in XAML it is a resolved component in the Live Visual Tree, while when added in C# it is just "Control":
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
var grid = new Grid
{
ColumnSpacing = 10
};
grid.ColumnDefinitions.Add(new ColumnDefinition());
grid.ColumnDefinitions.Add(new ColumnDefinition());
var gridSplitter = new GridSplitter
{
ResizeBehavior = GridSplitter.GridResizeBehavior.BasedOnAlignment,
ResizeDirection = GridSplitter.GridResizeDirection.Auto,
HorizontalAlignment = HorizontalAlignment.Left,
};
var borderLeft = new Border
{
BorderThickness = new Thickness(1),
BorderBrush = new SolidColorBrush(Colors.Green)
};
var borderRight = new Border
{
BorderThickness = new Thickness(1),
BorderBrush = new SolidColorBrush(Colors.Red)
};
grid.Children.Add(borderRight);
grid.Children.Add(borderLeft);
Grid.SetColumn(borderRight, 1);
Grid.SetColumn(borderLeft, 0);
Grid.SetColumn(gridSplitter, 1);
grid.Children.Add(gridSplitter);
Content = grid;
}
}
Steps to reproduce
1. Create new Winui Desktop App unpackaged.
2. Ensure Windows App SDK package version is 1.6.240829007
3. Ensure <TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
4. Add nuget package CommunityToolkit.WinUI.Controls.Sizers 8.1.240821
5. Use code from issue to reproduce
Expected behavior
The GridSplitter is visible when added in C#, like it is visible when added in XAML.
Additional investigations: Other controls like a radial Gauge can be added without any problems. But the grid splitter can't even be added with 8.0.230907 or 8.0.240109:
Describe the bug
Adding a GridSplitter in C# will not let it render. Adding it in XAML though will let it render. Also: When added in XAML it is a resolved component in the Live Visual Tree, while when added in C# it is just "Control":
Added in XAML:
MainWindow XAML:
MainWindow C#:
Added in C#:
MainWindow XAML:
MainWindow C#:
Steps to reproduce
Expected behavior
The GridSplitter is visible when added in C#, like it is visible when added in XAML.
Screenshots
No response
Code Platform
Windows Build Number
Other Windows Build number
Windows 11 24H2 26100.1591
App minimum and target SDK version
Other SDK version
No response
Visual Studio Version
2022, Preview
Visual Studio Build Number
Version 17.12.0 Preview 1.0
Device form factor
Desktop
Additional context
No response
Help us help you
No, I'm unable to contribute a solution.