Skip to content

Commit

Permalink
fix jimmejardine#292 : using a Grid Filler a la ToggleButton, which d…
Browse files Browse the repository at this point in the history
…idn't suffer from this issue. !@#$%^&* WPF
  • Loading branch information
GerHobbelt committed Jan 17, 2021
1 parent ddbac8d commit 384e13b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Utilities/GUI/AugmentedButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local_gui="clr-namespace:Utilities.GUI"
>
<DockPanel x:Name="ObjPanel" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<DockPanel x:Name="ObjPanel" Background="Transparent">
<Grid x:Name="PanelPopupPanel" DockPanel.Dock="Right" Width="20" Margin="1,0,0,0" >
<Image x:Name="ImagePopupIndicator" Width="8" Height="8"/>
</Grid>
<Image x:Name="ImageIcon" Width="32" Height="32" Visibility="Collapsed" />
<TextBlock x:Name="TextCaption" Visibility="Collapsed" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5,0" MinWidth="25" ></TextBlock>
<TextBlock x:Name="TextCaption" Visibility="Collapsed" TextWrapping="Wrap" Margin="5,0" MinWidth="25" />
<Grid Name="GridFiller" />
</DockPanel>
</Button>
7 changes: 5 additions & 2 deletions Utilities/GUI/AugmentedButton.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public AugmentedButton()
HorizontalAlignment = HorizontalAlignment.Stretch;
VerticalAlignment = VerticalAlignment.Stretch;

TextCaption.HorizontalAlignment = HorizontalAlignment.Stretch;
TextCaption.VerticalAlignment = VerticalAlignment.Stretch;

RenderOptions.SetBitmapScalingMode(ImageIcon, BitmapScalingMode.HighQuality);

IsEnabledChanged += AugmentedButton_IsEnabledChanged;
Expand Down Expand Up @@ -58,9 +61,9 @@ public AugmentedButton()
{
Caption = "Sample in DesignMode";
}
if (Icon == null || Icon.Width < 1 || Icon.Height < 1)
if (ImageIcon == null || ImageIcon.Source == null || ImageIcon.Width < 1 || ImageIcon.Height < 1)
{
Icon = Icons.GetAppIcon(Icons.SaveAs);
ImageIcon.Source = Icons.GetAppIcon(Icons.SaveAs);
}
}
#endif
Expand Down

0 comments on commit 384e13b

Please sign in to comment.