- Heia Samahi
- Posts: 8
- Joined:
[Unity][Bug?] Negative Padding crashes complete UI on load
Hello,
I have a XAML Style where I want to produce an overflow text on a button.
Works obviously great in MS Blend. But crash the UI complete in Noesis.
I've tested it so far that I can say that as soon as there's only a single minus sign in Padding, it crashes.
I hope it's a bug, how else should I create a text that overlays the button? Although there is still a way, but Padding in Noesis should be able to do that in my opinion.
If it's a bug, it's also possible to open an entry in the bug tracker, but I'm not sure.
Btw...
Removing all minus works great like this:
Here the complete XAML if you need it.
I have a XAML Style where I want to produce an overflow text on a button.
Code: Select all
<Setter Property="Padding" Value="-1,-10,-1,-2"/>
I've tested it so far that I can say that as soon as there's only a single minus sign in Padding, it crashes.
I hope it's a bug, how else should I create a text that overlays the button? Although there is still a way, but Padding in Noesis should be able to do that in my opinion.
If it's a bug, it's also possible to open an entry in the bug tracker, but I'm not sure.
Code: Select all
NoesisException: '-1,-10,-1,-2' (.?AV?$Boxed@UThickness@Noesis@@@Noesis@@) is not a valid value for property 'Border.Padding'
Rethrow as NoesisException
Noesis.Error.Check () (at Assets/NoesisGUI/Plugins/API/Core/NoesisError.cs:17)
Noesis.View.Noesis_View_Create_ (HandleRef content) (at Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:402)
Noesis.View..ctor (Noesis.FrameworkElement content) (at Assets/NoesisGUI/Plugins/API/Core/NoesisView.cs:386)
NoesisView.CreateView (Noesis.FrameworkElement content) (at Assets/NoesisGUI/Plugins/NoesisView.cs:1036)
NoesisView.LoadXaml (Boolean force) (at Assets/NoesisGUI/Plugins/NoesisView.cs:340)
NoesisView.OnEnable () (at Assets/NoesisGUI/Plugins/NoesisView.cs:398)
Removing all minus works great like this:
Code: Select all
<Setter Property="Padding" Value="1,10,1,2"/>
Code: Select all
<UserControl x:Class="CaveDigger.UI.Views.Controls.ChunkEditView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CaveDigger.UI.Views.Controls"
xmlns:hkConverters="clr-namespace:HeiKyu.Framework.XAML.Converter;assembly=HeiKyu.Framework.XAML"
xmlns:world="clr-namespace:CaveDigger.Scripts.World"
mc:Ignorable="d" >
<Grid Background="{DynamicResource Brush.Background.Sidebar}" VerticalAlignment="Top" Margin="0">
<StackPanel>
<Label Content="Press CTRL to avoid confirmation" Style="{DynamicResource LabelNormal}" />
<Grid>
<Grid.Resources>
<Style x:Key="ButtonPlusMinus" TargetType="{x:Type Button}">
<Setter Property="Width" Value="20"/>
<Setter Property="Height" Value="20"/>
<Setter Property="FontSize" Value="25"/>
<Setter Property="Padding" Value="-1,-10,-1,-2"/>
</Style>
<Style x:Key="ButtonPlus" TargetType="{x:Type Button}" BasedOn="{StaticResource ButtonPlusMinus}">
<Setter Property="Content" Value="+"/>
<Setter Property="Background" Value="{DynamicResource Brush.Background.LightBlue}"/>
<Setter Property="Command" Value="{Binding DataContext.ChunkAddCommand, ElementName=MainEditor}"/>
</Style>
<Style x:Key="ButtonMinus" TargetType="{x:Type Button}" BasedOn="{StaticResource ButtonPlusMinus}">
<Setter Property="Content" Value="-"/>
<Setter Property="Background" Value="{DynamicResource Brush.Background.LightRed}"/>
<Setter Property="Command" Value="{Binding DataContext.ChunkRemoveCommand, ElementName=MainEditor}"/>
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Content="{Binding DataContext.ChunkRemainingLabelZP, ElementName=MainEditor}" Grid.Column="2" Grid.Row="1" Style="{DynamicResource LabelNormal}"/>
<Label Content="{Binding DataContext.ChunkRemainingLabelXP, ElementName=MainEditor}" Grid.Column="3" Grid.Row="2" Style="{DynamicResource LabelNormal}"/>
<Label Content="{Binding DataContext.ChunkRemainingLabelZM, ElementName=MainEditor}" Grid.Column="2" Grid.Row="3" Style="{DynamicResource LabelNormal}"/>
<Label Content="{Binding DataContext.ChunkRemainingLabelXM, ElementName=MainEditor}" Grid.Column="1" Grid.Row="2" Style="{DynamicResource LabelNormal}"/>
<StackPanel Orientation="Vertical" Grid.Column="2" Grid.Row="0">
<Button Style="{DynamicResource ButtonPlus}" CommandParameter="{x:Static world:Orientation.ZP}" IsEnabled="{Binding DataContext.ChunkCanAddZP, ElementName=MainEditor}"/>
<Button Style="{DynamicResource ButtonMinus}" CommandParameter="{x:Static world:Orientation.ZP}" IsEnabled="{Binding DataContext.ChunkCanRemoveZP, ElementName=MainEditor}"/>
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2" Grid.Row="5">
<Button Style="{DynamicResource ButtonMinus}" CommandParameter="{x:Static world:Orientation.ZM}" IsEnabled="{Binding DataContext.ChunkCanAddZM, ElementName=MainEditor}"/>
<Button Style="{DynamicResource ButtonPlus}" CommandParameter="{x:Static world:Orientation.ZM}" IsEnabled="{Binding DataContext.ChunkCanRemoveZM, ElementName=MainEditor}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="2">
<Button Style="{DynamicResource ButtonPlus}" CommandParameter="{x:Static world:Orientation.XM}" IsEnabled="{Binding DataContext.ChunkCanAddXM, ElementName=MainEditor}"/>
<Button Style="{DynamicResource ButtonMinus}" CommandParameter="{x:Static world:Orientation.XM}" IsEnabled="{Binding DataContext.ChunkCanRemoveXM, ElementName=MainEditor}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Column="5" Grid.Row="2">
<Button Style="{DynamicResource ButtonMinus}" CommandParameter="{x:Static world:Orientation.XP}" IsEnabled="{Binding DataContext.ChunkCanAddXP, ElementName=MainEditor}"/>
<Button Style="{DynamicResource ButtonPlus}" CommandParameter="{x:Static world:Orientation.XP}" IsEnabled="{Binding DataContext.ChunkCanRemoveXP, ElementName=MainEditor}"/>
</StackPanel>
</Grid>
</StackPanel>
</Grid>
</UserControl>
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: [Unity][Bug?] Negative Padding crashes complete UI on load
When you say that it crashes the UI completely you mean an unhandled exception that closes Unity? If that's the case, could you please create a report in our bugtracker and attach a minidump of the crash so we can analyze why is occurring, because I'm not able to get a crash.
If what you see is simply an error message in the Unity console that is intended, as negative paddings are not allowed in a Border, and our Button default template binds Control.Padding property to its template Border.Padding. Maybe we can change the template to bind to the template ContentPresenter.Margin instead to allow negative Control.Padding, so it behaves the same as WPF default styles.
Meanwhile you can do just that in your application if you need negative paddings:
If what you see is simply an error message in the Unity console that is intended, as negative paddings are not allowed in a Border, and our Button default template binds Control.Padding property to its template Border.Padding. Maybe we can change the template to bind to the template ContentPresenter.Margin instead to allow negative Control.Padding, so it behaves the same as WPF default styles.
Meanwhile you can do just that in your application if you need negative paddings:
Code: Select all
<ControlTemplate x:Key="ButtonTemplate" TargetType="{x:Type ButtonBase}">
<Border x:Name="Bg"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="1">
<ContentPresenter
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
...
</ControlTemplate>
Who is online
Users browsing this forum: Ahrefs [Bot] and 8 guests