Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChildWindow position when it appears. #103

Closed
DeputyOfCopyPaster opened this issue Oct 8, 2019 · 25 comments · Fixed by #104
Closed

ChildWindow position when it appears. #103

DeputyOfCopyPaster opened this issue Oct 8, 2019 · 25 comments · Fixed by #104
Milestone

Comments

@DeputyOfCopyPaster
Copy link

DeputyOfCopyPaster commented Oct 8, 2019

hello everyone!
Is there a way to set a certain ChildWindow position when it appears? At the moment it appears exact in the middle of the screen and even I move it to a certain place, next time (after App restart), it appears in the middle of the screen as it was before.
Is there a way to save this position?

thanks in advance!

@timunie
Copy link
Contributor

timunie commented Oct 8, 2019

Hi @DeputyOfCopyPaster If I remember correctly you can use the Margin property to define the position of a child window. I don't have a PC at the moment so i could not check it right now.

Happy coding Tim

@DeputyOfCopyPaster
Copy link
Author

DeputyOfCopyPaster commented Oct 8, 2019

Hi @DeputyOfCopyPaster If I remember correctly you can use the Margin property to define the position of a child window. I don't have a PC at the moment so i could not check it right now.

Happy coding Tim

I don't think so, the Margin isn't a proper way to do that. The ChWindow isn't a static control.
There should be a cleverer way, definetely.
So, please check it and tell me how to do that by a proper way. I'm just out of any ideas.

thanks in advance!

@timunie
Copy link
Contributor

timunie commented Oct 9, 2019

Hi @DeputyOfCopyPaster ,
I had a look in the source code and as far as I can see (I'm not a programmer ;-) ) there is currently no buit in way to save the window position...

Workaround
You are correct, it wasn't Margin that I was looking for, it was Padding. You can take this property as a work around:
Let`s assume you have the following parameters set:

 VerticalContentAlignment = VerticalAlignment.Top;
 HorizontalContentAlignment = HorzontalAlignment.Left;

When you close the ChildWindow you have to calculate the offset from left and top and save these value somewhere, e.g. in the Properties. When you call the ChildWindow again, you can then initilize it with these values:

Padding = new Thickness(SavedLeftPosition, SavedTopPosition, 0, 0);

But please keep in mind, the MainWindow may have changed it's size and the ChildWindow might be outside of the MainWindow. This has to be cached I think.

Built in soultion
As far as I can see there has to be two new Properties OffsetX and OffsetY to enable what you are looking for. I don't know if @punker76 wants this feature or not. If he gives me the go, I will try to implement these Properties.

Happy coding
Tim

@DeputyOfCopyPaster
Copy link
Author

DeputyOfCopyPaster commented Oct 13, 2019

@timunie, hello

Hi @DeputyOfCopyPaster ,
I had a look in the source code and as far as I can see (I'm not a programmer ;-) ) there is currently no buit in way to save the window

I'm just a deputy of CopyPaster and CopyPaster itself is one of deputies of true Programmer. ;)
I will test those new properties soon.

thanks a lot!

@timunie
Copy link
Contributor

timunie commented Oct 14, 2019

Hi @DeputyOfCopyPaster ,

I took another gif to show you that it is possible to remember the position (I see you got it and changed your question, but I am already done with the new gif :-) ).

ChildWindow_RememberPosition

Happy coding
Tim

@DeputyOfCopyPaster
Copy link
Author

DeputyOfCopyPaster commented Oct 14, 2019

@timunie, hi there
Yes I've got (not at once :)) that you did exactly what I meant. So I had changed my post.
Could you tell me where have you done changes? ChWindow version?
release

@timunie
Copy link
Contributor

timunie commented Oct 14, 2019

@DeputyOfCopyPaster, at the moment it is just a PR. I don't know if it will be ever available, @punker76 has to decide 👍 or 👎

@DeputyOfCopyPaster
Copy link
Author

DeputyOfCopyPaster commented Oct 14, 2019

Why not? Missing of that just deprives ChWindow of some usability, I believe.
The ChWindows must pop up at place where it was planned by end user. 👍

@timunie
Copy link
Contributor

timunie commented Oct 14, 2019

I am not the owner of this repro and don't have write permissions, so I am unable to do.

@DeputyOfCopyPaster
Copy link
Author

never mind, hope owners follow our chat...

@punker76 punker76 added this to the 2.0.0 milestone Oct 15, 2019
punker76 added a commit to timunie/MahApps.Metro.SimpleChildWindow that referenced this issue Oct 15, 2019
Added `OffsetX` and `OffsetY` DepencyProperty to allow storing the relative position of the child window.
@DeputyOfCopyPaster
Copy link
Author

DeputyOfCopyPaster commented Oct 18, 2019

@timunie, @punker76,
Guys, I am not familiar with Github system at all, so please enlighten me what is the status of this ChWindow feature. May I use it? Or?

thank you!

@timunie
Copy link
Contributor

timunie commented Oct 18, 2019

@DeputyOfCopyPaster yes if you uae the latest prerelease

@DeputyOfCopyPaster
Copy link
Author

DeputyOfCopyPaster commented Oct 18, 2019

@DeputyOfCopyPaster yes if you uae the latest prerelease

@timunie, How do I find the latest prerelease? I mean where is prerelease located?

@timunie
Copy link
Contributor

timunie commented Oct 25, 2019

Hi @DeputyOfCopyPaster ,

sorry for the late replay. Set this checkmark in your Nuget-Manager:
image

Happy testing
Tim

@DeputyOfCopyPaster
Copy link
Author

DeputyOfCopyPaster commented Oct 28, 2019

@timunie,
hi there,
just have assembled a test project based on yours all latest prereleases, as you had showed me above.
Perhaps I have missed something. The ChildWindow still doesn't remember its previous position.
A missed parameter in ChWindow_01.xaml?
Today is Monday, though... :)

ChWindow_01

@timunie
Copy link
Contributor

timunie commented Oct 28, 2019

Hi @DeputyOfCopyPaster ,
As you can have more than one CW that you might want to rember, there is no build in way to save the position. You will need to save OffsetX and OffsetY on your own. see: https://docs.microsoft.com/de-de/visualstudio/ide/managing-application-settings-dotnet?view=vs-2015&redirectedfrom=MSDN

Happy coding
Tim

@DeputyOfCopyPaster
Copy link
Author

DeputyOfCopyPaster commented Oct 28, 2019

@timunie, it seems I've gotten a remembering of ChWindow previous position.
However, why I'm getting at left upper corner -negative values and at right lower corner -positive values? As per GIF attached. Please give me an idea. Normally they should be positive within mother's window.

neg_values

@timunie
Copy link
Contributor

timunie commented Oct 28, 2019

@DeputyOfCopyPaster it depends on the HorizontalAlignment and VerticalAlignment

@DeputyOfCopyPaster
Copy link
Author

@timunie. I don't see any alignment properties used in your latter demo release.

@timunie
Copy link
Contributor

timunie commented Oct 28, 2019

the default is center, so the Point (0,0) is in the middle ...

@DeputyOfCopyPaster
Copy link
Author

DeputyOfCopyPaster commented Oct 28, 2019

@timunie, while playing around I've noticed one more thing which brings some discomfort in ChildWindow usage. As practice shows, the left upper ChildWindow's corner (mostly it's icons area) is not sensitive for dragging. In other words it doesn't allow to hide ChildWindow more deeper.
It's possible to hide a bit more, though.
@timunie, look, I'm not speaking about hiding entirely, I'm speaking about hiding a bit more than we can at the moment.
So, my question is, is there a way to leave icon at its place and get icon's area to be sensitive for dragging?

So, what do you think about?

ChWindow_icon

@timunie
Copy link
Contributor

timunie commented Oct 28, 2019

to be honest I don't see a reason why one should move the childwindow out of the parent window. Maybe you should consider to open a new MetroWindow.

Happy dragging
Tim

@DeputyOfCopyPaster
Copy link
Author

to be honest I don't see a reason why one should move the childwindow out of the parent window. Maybe you should consider to open a new MetroWindow.

Happy dragging
Tim

@timunie, Yeah, I see you don't know. However, many end users know some reasons.
Since the ChildWindows are essentially dialogues, what would you do with a few annoying dialogues which pop up for some reasons every 5 seconds on your screen, for example? Our end users just hide them nearly out of the screen.
So, in terms of usabiliity the dragging here is realized pretty poorly.

In other words the icon must not interfere to happy dragging of end users.

@DeputyOfCopyPaster
Copy link
Author

DeputyOfCopyPaster commented Oct 29, 2019

@timunie, I decided to make some changes and set the property IsOpen="true", and have seen the following stuff, as per image attached.
Perhaps you now how to put ChildWindow in the center of so-called "design-time". For some reasons it always located not in the middle. I've tried to apply different kinds of allignments. It didn't affect.

Xaml_designer

@timunie
Copy link
Contributor

timunie commented Oct 30, 2019

@DeputyOfCopyPaster
please try:

HorizontalContentAlignment="Right"
VerticalContentAlignment="Bottom"

But please keep in mind that even this will not solve all the positioning issues you might have. And unfortunatally I don't have the time to rewrite all the stuff needed to archiev your goal.

One personal oppinion from my side: If I were your customer and the ChildWindow would open so often, I would ask if this is the right Control / UserInterface for what you are trying to archiev. We can discuss this in a private gitter room, if you want to, please not here.

I hope you understand that I will now leave this issue as it is right now.

Happy coding
Tim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants