❔ WPF Button is only 2 pixels wide at runtime and I don't know why

I have the following control in my WPF form:
<Button
x:Name="btnGeneralConnectionEnableIdentServerReset"
Style="{DynamicResource ResetPrefBtn}" />
<Button
x:Name="btnGeneralConnectionEnableIdentServerReset"
Style="{DynamicResource ResetPrefBtn}" />
I also have the following in my App.xaml:
<Style
x:Key="ResetPrefBtn" TargetType="Button">
<Setter
Property="BorderThickness"
Value="0" />
<Setter
Property="Background"
Value="Transparent" />
<Setter
Property="Content">
<Setter.Value>
<Image
Source="/Reset Pref.png" />
</Setter.Value>
</Setter>
<Setter
Property="ToolTip"
Value="Reset this preference to the default"/>
</Style>
<Style
x:Key="ResetPrefBtn" TargetType="Button">
<Setter
Property="BorderThickness"
Value="0" />
<Setter
Property="Background"
Value="Transparent" />
<Setter
Property="Content">
<Setter.Value>
<Image
Source="/Reset Pref.png" />
</Setter.Value>
</Setter>
<Setter
Property="ToolTip"
Value="Reset this preference to the default"/>
</Style>
At runtime, this button is only 2 pixels wide. I checked in the Visual Source tree and it lists that value. Now many here have told me not to use the designer, but I'm a rather visual person who needs the feedback it provides. And it has the button displayed as I'd expect with a width of 18.002233505249. Looks different too. I figure it uses a different layout engine. So can someone explain what I need to do to get it to display the width I'd expect without hard coding the width?
1 Reply
Accord
Accord15mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server