Hide buttons in AdonisWindow according to ResizeMode#38
Hide buttons in AdonisWindow according to ResizeMode#38benruehl merged 2 commits intobenruehl:masterfrom
Conversation
benruehl
left a comment
There was a problem hiding this comment.
Thanks a lot for adressing this issue!
I think the solution could be improved by moving the setter of the disabled foreground to the WindowButton style. It would work for all window buttons when they are disabled and not just for this specific case.
|
We should also check if the window buttons are the only things that need to respect the ResizeMode. Maximizing can also be done using shortcuts, double-clicking the title bar and dragging the window to the top of the screen. Maybe these things need to be adressed as well. I will look into that soon. |
|
@benruehl Thanks for your feedback.
I did try this before, but somehow could not get it to work. It seems the triggers in the WindowButton style are overriden by the values of the control template. The current is the only solution I could think of.
Made a quick check for those and everything already seems to behave as expected. Looks like someone already thought about that :) adonis-ui/AdonisUI/Controls/AdonisWindow.cs Lines 225 to 229 in bb2bfbe |
|
You are right, I see what you mean, sorry! The only alternative I can think of is a trigger in the <ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" TargetName="ContentPresenter" Value="{DynamicResource {x:Static adonisUi:Brushes.DisabledForegroundBrush}}"/>
</Trigger>
</ControlTemplate.Triggers>(Assuming the This solution has the disadvantage that it is built directly into the template which means the behavior cannot be customized from the outside anymore. What do you think? If you don't like the idea, we can use your current solution as well. |
|
@benruehl You're alternative solution makes more sense to me as it is more generic. However, setting |
|
Seems like I forgot to mention that the button's <Button x:Name="PART_MaximizeRestoreButton"
Grid.Column="1"
Style="{DynamicResource {x:Static adonisUi:Styles.WindowButton}}"
Foreground="{TemplateBinding TitleBarForeground}"
Background="{TemplateBinding WindowButtonHighlightBrush}">
<Button.ContentTemplate>
<DataTemplate>
<ContentControl ContentTemplate="{DynamicResource {x:Static adonisUi:Icons.WindowMaximize}}"
Width="10"
Height="10"/>
</DataTemplate>
</Button.ContentTemplate>
</Button>I am not sure why this changes the behavior though. Read about it in punker76's blog. Does it work for you now? |
|
Thanks, this does work for me now. I pushed the changes. |
|
Awesome. Again, thanks a lot for this contribution. Appreciate it. |
The default WPF window hides the minimize and maximize buttons if
ResizeModeis set toNoResize. Also, the maximize button is disabled if it's set toCanMinimize[link].This PR adds this behaviour for
AdonisWindow.PS: Thanks for your great work on this library!