punker76 / MahApps.Metro.SimpleChildWindow

A simple child window for MahApps.Metro
MIT License
374 stars 55 forks source link

Can't reopen SimpleChildWindow #10

Closed riegaz closed 9 years ago

riegaz commented 9 years ago

Could you please help me? Once closed the window it does not reopen. With the code below you should be able to verify this behaviour.

It should open and close every 3 seconds but it never reopens.

Thanks for help!

In XAML:

simpleChildWindow:ChildWindow IsOpen="{Binding showwarning}"

In a task I run:

 while (true)
            {
                Thread.Sleep(3000);
                if (showwarning)
                { showwarning = false; Console.WriteLine("OFF"); }
                else
                { showwarning = true; Console.WriteLine("ON"); }
            }

showwarning is of type (typical wpf structure):

private bool _showwarning = false;
        public bool showwarning
        {
            get
            { return _showwarning; }
            set
            {
                //Console.WriteLine("change");
               // if (_showwarning == value) { return; }
                _showwarning = value;
                RaisePropertyChanged("showwarning");
            }
        }
punker76 commented 9 years ago

@riegaz i've implemented this short example in the demo and it works on my machine™

test

riegaz commented 9 years ago

I checked your examples. You set the "IsOpen" in the code behind but not via a Binding. For me like this it is also working but once I bind it, it does only work once.

Here is a basic example.

https://mega.co.nz/#!vwoBCSbR!BdwRvnu2rjgzfxQu0KXgfj32PgOyEw3Uc4wc8UEpzvQ

It contains the mvvm pattern where a bool is toggled between true and false every 3 seconds. This bool is bound to your subwindow. As you can see, it only works once.

riegaz commented 9 years ago

Can you reproduce the behaviour?

riegaz commented 9 years ago

Please let me know if you plan to fix this problem, because I'm waiting right now for your response. Any response is welcome, I just need to know if I have to implement something on my own.

punker76 commented 9 years ago

@riegaz i really don't know what's going wrong here, but i'll look into

riegaz commented 9 years ago

Thank you. I used a converter to convert the bound variable from number to boolean. Once the subwindow does not respond anymore, also the converter does not get notified anymore. It looks like the dependencyobject is somehow unregistered or overwritten vor lost? Maybe it would be interesting to see if it happens from on to offand also from off to on.

merso0027 commented 9 years ago

I have same issue. Do you have any solution for this?

punker76 commented 9 years ago

@merso0027 do you also use MVVMLight?

agc93 commented 9 years ago

I see you've removed it from 1.2.0. Has there been any progress on this? Or do we need to roll our own replacement just to get MVVM Binding working?

I have the same issue using only the built-in WPF Bindings and properties, no MVVMLight or other frameworks. Same issue: can be toggled on, then off, and then no longer responds.

punker76 commented 9 years ago

@riegaz @merso0027 @agc93 you can test the 1.3.0-ALPHA001 which should fix this nasty bug...

agc93 commented 9 years ago

Just wanted to confirm and say that the new version works like a dream for me. Installed from the prerelease Nuget package, worked first time. Thanks heaps!!