DevFear
Topic Author
Posts: 53
Joined: 29 Jun 2022, 12:36

Override StackPanel ?

11 May 2023, 18:18

When inheriting from the standard StackPanel, my custom Stack works differently. In the WPF context, the StackPanel also automatically changes its height depending on the child elements. But in Noesis, my custom StackPanel does not adjust to the child elements.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Override StackPanel ?

12 May 2023, 11:23

The StackPanel will fit the height of its children when its VerticalAlignment is set to Center, Top or Bottom. If it is set to stretch, then it depends on the height of the parent container. This is because ArrangeOverride is implemented in StackPanel to return the available space in the parent container.
What is the structure of the xaml containing your StackPanel? How are you implementing ArrangeOverride? Could you paste here that info?
 
DevFear
Topic Author
Posts: 53
Joined: 29 Jun 2022, 12:36

Re: Override StackPanel ?

12 May 2023, 11:38

Of course, here is an example of how my Layout StackPanel works calmly in the WPF editor.
Perhaps you need to implement something yourself?
Image
Code:
	public class LayoutStackPanel : StackPanel
	{
		
	}
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Override StackPanel ?

12 May 2023, 13:42

I've tried to extend StackPanel and found that it was not creating the correct native proxy. This is a bug, could you please report it in our bugtracker?
It is creating a simple Panel, not a StackPanel, this is why you were seeing nothing inside the StackPanel.

Although we need to properly fix this I found a workaround you can easily apply by modifying Extend.cs in our plugin:
Index: Extend.cs
===================================================================
--- Extend.cs	(revision 12519)
+++ Extend.cs	(working copy)
@@ -1344,7 +1344,14 @@
                 else if (typeof(Noesis.IScrollInfo).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()) &&
                     typeof(Noesis.Panel).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()))
                 {
-                    nativeType = Noesis.ExtendScrollInfo.Extend(TypeFullName(type));
+                    if (typeof(Noesis.StackPanel).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()))
+                    {
+                        nativeType = Noesis.StackPanel.Extend(TypeFullName(type));
+                    }
+                    else
+                    {
+                        nativeType = Noesis.ExtendScrollInfo.Extend(TypeFullName(type));
+                    }
                 }
                 else if (type.GetTypeInfo().IsSubclassOf(typeof(Noesis.BaseComponent)))
                 {
 
DevFear
Topic Author
Posts: 53
Joined: 29 Jun 2022, 12:36

Re: Override StackPanel ?

15 May 2023, 11:51

Who is online

Users browsing this forum: No registered users and 93 guests