@@ -993,34 +993,92 @@ private bool CanExecuteDelegate(Core.Models.PropertyDescriptor prop, object targ
993993 /// </summary>
994994 private void ApplyControlAttributes ( global ::Avalonia . Controls . Control control , Core . Models . PropertyDescriptor prop , object target )
995995 {
996- var propertyInfo = GetPropertyInfo ( target , prop . PropertyName ) ;
997- if ( propertyInfo != null )
998- {
999- // Apply layout attributes
1000- control . ApplyLayout ( propertyInfo ) ;
996+ // Apply layout from pre-generated PropertyDescriptor (AOT-safe)
997+ ApplyLayoutFromDescriptor ( control , prop ) ;
1001998
1002- // Apply placeholder to TextBox
1003- if ( control is TextBox textBox )
1004- {
1005- textBox . ApplyPlaceholder ( propertyInfo ) ;
1006- }
1007-
1008- // Apply description (tooltip)
1009- control . ApplyDescription ( propertyInfo ) ;
1010- }
1011-
1012- // AOT-safe fallback using generated metadata
1013- if ( control is TextBox tb && ! string . IsNullOrEmpty ( prop . PlaceholderText ) )
999+ // Apply placeholder to TextBox
1000+ if ( control is TextBox textBox && ! string . IsNullOrEmpty ( prop . PlaceholderText ) )
10141001 {
1015- tb . Watermark = prop . PlaceholderText ;
1002+ textBox . Watermark = prop . PlaceholderText ;
10161003 }
10171004
1005+ // Apply description (tooltip)
10181006 if ( ! string . IsNullOrEmpty ( prop . DescriptionText ) )
10191007 {
10201008 ToolTip . SetTip ( control , prop . DescriptionText ) ;
10211009 }
10221010 }
10231011
1012+ /// <summary>
1013+ /// Applies layout properties from PropertyDescriptor (AOT-safe, no reflection).
1014+ /// </summary>
1015+ private static void ApplyLayoutFromDescriptor ( global ::Avalonia . Controls . Control control , Core . Models . PropertyDescriptor prop )
1016+ {
1017+ if ( ! double . IsNaN ( prop . LayoutWidth ) ) control . Width = prop . LayoutWidth ;
1018+ if ( ! double . IsNaN ( prop . LayoutHeight ) ) control . Height = prop . LayoutHeight ;
1019+ if ( ! double . IsNaN ( prop . LayoutMinWidth ) ) control . MinWidth = prop . LayoutMinWidth ;
1020+ if ( ! double . IsNaN ( prop . LayoutMinHeight ) ) control . MinHeight = prop . LayoutMinHeight ;
1021+ if ( ! double . IsNaN ( prop . LayoutMaxWidth ) ) control . MaxWidth = prop . LayoutMaxWidth ;
1022+ if ( ! double . IsNaN ( prop . LayoutMaxHeight ) ) control . MaxHeight = prop . LayoutMaxHeight ;
1023+
1024+ if ( ! string . IsNullOrEmpty ( prop . LayoutHorizontalAlignment ) )
1025+ control . HorizontalAlignment = ParseHorizontalAlignment ( prop . LayoutHorizontalAlignment ) ;
1026+
1027+ if ( ! string . IsNullOrEmpty ( prop . LayoutVerticalAlignment ) )
1028+ control . VerticalAlignment = ParseVerticalAlignment ( prop . LayoutVerticalAlignment ) ;
1029+
1030+ if ( ! string . IsNullOrEmpty ( prop . LayoutMargin ) )
1031+ control . Margin = ParseThickness ( prop . LayoutMargin ) ;
1032+
1033+ if ( ! string . IsNullOrEmpty ( prop . LayoutPadding ) )
1034+ {
1035+ var padding = ParseThickness ( prop . LayoutPadding ) ;
1036+ if ( control is ContentControl contentControl )
1037+ contentControl . Padding = padding ;
1038+ else if ( control is Decorator decorator )
1039+ decorator . Padding = padding ;
1040+ }
1041+ }
1042+
1043+ private static HorizontalAlignment ParseHorizontalAlignment ( string ? value )
1044+ => value ? . ToLowerInvariant ( ) switch
1045+ {
1046+ "left" => HorizontalAlignment . Left ,
1047+ "center" => HorizontalAlignment . Center ,
1048+ "right" => HorizontalAlignment . Right ,
1049+ "stretch" => HorizontalAlignment . Stretch ,
1050+ _ => HorizontalAlignment . Stretch
1051+ } ;
1052+
1053+ private static VerticalAlignment ParseVerticalAlignment ( string ? value )
1054+ => value ? . ToLowerInvariant ( ) switch
1055+ {
1056+ "top" => VerticalAlignment . Top ,
1057+ "center" => VerticalAlignment . Center ,
1058+ "bottom" => VerticalAlignment . Bottom ,
1059+ "stretch" => VerticalAlignment . Stretch ,
1060+ _ => VerticalAlignment . Stretch
1061+ } ;
1062+
1063+ private static Thickness ParseThickness ( string ? value )
1064+ {
1065+ if ( string . IsNullOrEmpty ( value ) ) return new Thickness ( 0 ) ;
1066+
1067+ var parts = value . Split ( ',' ) . Select ( p => p . Trim ( ) ) . ToArray ( ) ;
1068+
1069+ if ( parts . Length == 1 && double . TryParse ( parts [ 0 ] , out var uniform ) )
1070+ return new Thickness ( uniform ) ;
1071+
1072+ if ( parts . Length == 4 &&
1073+ double . TryParse ( parts [ 0 ] , out var left ) &&
1074+ double . TryParse ( parts [ 1 ] , out var top ) &&
1075+ double . TryParse ( parts [ 2 ] , out var right ) &&
1076+ double . TryParse ( parts [ 3 ] , out var bottom ) )
1077+ return new Thickness ( left , top , right , bottom ) ;
1078+
1079+ return new Thickness ( 0 ) ;
1080+ }
1081+
10241082 /// <summary>
10251083 /// Creates a TextBox with password support and validation.
10261084 /// </summary>
0 commit comments