MaterialDesignInXAML / MaterialDesignInXamlToolkit

Google's Material Design in XAML & WPF, for C# & VB.Net.
http://materialdesigninxaml.net
MIT License
15.23k stars 3.44k forks source link

DialogHost inheritance from Window? #2398

Closed Cohote closed 3 years ago

Cohote commented 3 years ago

On my Main Window, I have a default font-size specified:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    [...]
    FontSize="28pt"
    FontFamily="Segoe UI Semibold">

And then, in a User Control, I have a DisloagHost defined:

<materialDesign:DialogHost DialogTheme="Inherit"
    CloseOnClickAway="True">

In the DialogHost, I have no <DialogHost.Content> defined, as I have two buttons that pass the content using the <Button.CommandParameter> property.

When these dialogs show, the FontFamily seems to be inherited, but the FontSize is not. Is this expected? If not, let me know and I can provide a small project that reproduces it.

Keboo commented 3 years ago

Hi @Cohote

It looks like that is likely a bug. Specifically caused by these lines here: https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/b9562c46f28dea7e012fda1a986a1dd919e2bd92/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DialogHost.xaml#L158-L163

I would say that is certainly not expected and should get fixed.

I suspect we could likely simply omit those setters and test to make sure that the settings are properly inherited.

Cohote commented 3 years ago

Ah, awesome to see then. Let me know if you need anything else from me.

I'd love to tackle this and submit a pull request, but I need to finish this current project first, so it will be a little while before I can.

Cohote commented 3 years ago

Quick followup - I may actually try grabbing a copy of master and including it as a project on this solution and see if leaving those out actually does the trick. Give me a few days and I'll update here.

Cohote commented 3 years ago

Okay, adding the needed projects to my solution took less time than I thought.

Verified that removing lines 158-163 from that file worked. The font-size was inherited properly. I noticed that the lines 364-369 look like they also need to be removed, being used in the MaterialDesignEmbeddedDialogHost style. I haven't used that style in my application, so have no experience with that.

Also, removing the FocusManager.IsFocusScope="False" may also help with, for example, #1818 , depending on the inheritance of that property in the FocusManager. (Not sure if it'd defaulting to true or false in the wpf:Card there and the hierarchy above it.

Note that digging this deep into controls is not what I'm used to doing (I'm ususlaly a server-back-end kinda guy), so this is a learning experience.

Keboo commented 3 years ago

For a server-back-end kinda guy you are doing great ;). And yes I would expect that we want to remove the setters for the embedded dialog host as well. That one was largely a copy and paste of the main style so it does not surprise me. I will get a PR in for it later.

In terms of #1818 yes good catch, that is likely something to look into. I suspect we really don't need to manually manage the FocusScope like what we are doing (except perhaps in the embedded dialog host). The intent is that while the dialog has focus, pressing tab should loop through the controls within the dialog and not jump to the controls behind it.

Cohote commented 3 years ago

Thanks for this! And doing it quickly! Was going to try branching and submitting a PR this week. Appreciated again!