Materialdesigninxamltoolkit: Some dialogs have a surrounding line

Created on 4 Feb 2016  路  8Comments  路  Source: MaterialDesignInXAML/MaterialDesignInXamlToolkit

Like this: http://i.imgur.com/Il0lzRZ.png
Some dialogs have this line others dont. It seems to be random

Most helpful comment

That's great!

All fixed now, you can close this. Thank you!

All 8 comments

I think that's related to the focus visual not set to null on some style. that's the line that usually appears by default when tabbing between elements.

I get that, but I am not setting the focus visual to null on neither of my dialogs and still some have this line and some dont

Please re-test on latest and report back.

Thank you!

The line is gone, however there is another problem now. All dialogs which previously had this line can no longer be closed with

DialogHost.CloseDialogCommand.Execute(false, null);

and that makes the new version unusable for me. I am stuck with 1.4.1

OK...this kind of makes sense, as we have been messing with focus issues. Now we stopped part of the tree getting focus so you don't see the dotted lines, _but_ the knock on effect is that your DialogHost.CloseDialogCommand.Execute(false, null); line fails.

DialogHost.CloseDialogCommand is static, and it is a routed command, and therefore if there is no focus, there is nothing to execute on, & it won't work.

I don't know why certain of your dialogs are getting focus, and some not. I guess it's a timing thing, but it is unsafe to call DialogHost.CloseDialogCommand.Execute() as it depends on focus.

What's the wider context of how/where you are calling it from? View model? Code behind?

I have just found the cause of this problem. Having a dialog with no controls that can be focused makes the focus line visible in version 1.4 and the dialog unable to close in version 1.5. So simply adding a <TextBox Width="0" Height="0" /> somewhere in the dialog fixes the problem.

I am calling DialogHost.CloseDialogCommand.Execute() from view model. What other alternatives do I have for closing the dialog from view model?

I'm guessing you are using the .Show method?

If you use an overload where you provide a open event handler:

Show(object content, DialogOpenedEventHandler openedEventHandler)

You can get the DialogSession from the event args.

From the session you have the .Close() method.

That's great!

All fixed now, you can close this. Thank you!

Was this page helpful?
0 / 5 - 0 ratings