add border

This commit is contained in:
bluepilledgreat 2025-01-23 01:06:49 +00:00
parent bf64ec8af0
commit d8919e5aea
3 changed files with 43 additions and 0 deletions

View File

@ -140,6 +140,17 @@
"Orientation": "Orientation" "Orientation": "Orientation"
} }
}, },
"Border": {
"SuperClass": "FrameworkElement",
"IsCreatable": true,
"Attributes": {
"Background": "Brush",
"BorderBrush": "Brush",
"BorderThickness": "Thickness",
"Padding": "Thickness",
"CornerRadius": "CornerRadius"
}
},
"RowDefinition": { "RowDefinition": {
"IsCreatable": true, "IsCreatable": true,
"Attributes": { "Attributes": {

View File

@ -32,6 +32,7 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
["Image"] = HandleXmlElement_Image, ["Image"] = HandleXmlElement_Image,
["Grid"] = HandleXmlElement_Grid, ["Grid"] = HandleXmlElement_Grid,
["StackPanel"] = HandleXmlElement_StackPanel, ["StackPanel"] = HandleXmlElement_StackPanel,
["Border"] = HandleXmlElement_Border,
["SolidColorBrush"] = HandleXmlElement_SolidColorBrush, ["SolidColorBrush"] = HandleXmlElement_SolidColorBrush,
["ImageBrush"] = HandleXmlElement_ImageBrush, ["ImageBrush"] = HandleXmlElement_ImageBrush,

View File

@ -729,6 +729,37 @@ namespace Bloxstrap.UI.Elements.Bootstrapper
return stackPanel; return stackPanel;
} }
private static Border HandleXmlElement_Border(CustomDialog dialog, XElement xmlElement)
{
var border = new Border();
ApplyBrush_UIElement(dialog, border, "Background", Border.BackgroundProperty, xmlElement);
ApplyBrush_UIElement(dialog, border, "BorderBrush", Border.BorderBrushProperty, xmlElement);
object? borderThickness = GetThicknessFromXElement(xmlElement, "BorderThickness");
if (borderThickness != null)
border.BorderThickness = (Thickness)borderThickness;
object? padding = GetThicknessFromXElement(xmlElement, "Padding");
if (padding != null)
border.Padding = (Thickness)padding;
object? cornerRadius = GetCornerRadiusFromXElement(xmlElement, "CornerRadius");
if (cornerRadius != null)
border.CornerRadius = (CornerRadius)cornerRadius;
var children = xmlElement.Elements().Where(x => !x.Name.ToString().StartsWith("Border."));
if (children.Any())
{
if (children.Count() > 1)
throw new Exception("Border can only have one child");
border.Child = HandleXml<UIElement>(dialog, children.First());
}
return border;
}
#endregion #endregion
} }
} }