bodong1987 / Avalonia.PropertyGrid

A property edit control in Avalonia like DevExpress's PropertyGridControl.
https://www.cnblogs.com/bodong
MIT License
184 stars 19 forks source link

Fontsize of property values can not be set #26

Closed Jules196 closed 3 months ago

Jules196 commented 7 months ago

I am using version 11.0.6.2 of the PropertyGrid libary and version 11.0.10 of Avalonia. I want to set the fontsize like the following: <ScrollViewer Grid.Column="0" Grid.Row="1" FontSize="11"> <propGrid:PropertyGrid Name="propGrid" AllowFilter="False" ShowTitle="True" AllowQuickFilter="False" DataContext="{Binding Config}">

But it changes only the fontsize of the Textbox with property name, it does not changes the control elements of the property value
Jules196 commented 7 months ago

Current workaround to add Style elements: ` public MyView() { InitializeComponent(); propGrid.Loaded += PropGrid_Loaded; }

private void PropGrid_Loaded(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
    foreach (var c in (propGrid.Content as Grid)!.Children)
    {
        if (c is Grid gridLv1 && gridLv1.Name == "propertiesGrid")
        {
            foreach (var c2 in gridLv1.Children)
            {
                if (c2 is Expander exp && exp.Content is Grid gridLv2)
                {
                    gridLv2.RowDefinitions.ForEach(f => f.Height = GridLength.Auto);
                    foreach (var c3 in gridLv2.Children)
                    {
                        if (c3 is TemplatedControl tp)
                        {
                            tp.FontSize    = propGrid.FontSize;
                            tp.FontFamily  = propGrid.FontFamily;
                            tp.FontStretch = propGrid.FontStretch;
                            tp.FontWeight  = propGrid.FontWeight;
                            tp.Foreground  = propGrid.Foreground;
                        }
                    }
                }
            }
        }
    }
}`

Would it be great if there are Styleproperties for PropertyName, PropertyValue and Grouping Header?