I have a little problem with that. My window is created by costom window style, not like your’s. So I created borders in style and now there’s my problem. Border is created like that:
…
…
In that case I can’t call constructor like you do, cause first I need to get reference to that borders. That references I getting like this:
this.m_TopLeft = (FrameworkElement)this.Template.FindName(“m_TopLeft”, this);
I thought that now I can call the constructor, but there is a small problem – this element are not available when construction of window is performed, so this.m_TopLeft = null.
Hmm I thought ok, then I’ll get those references on window event Loaded. So now I have my needed references to border’s in Loaded event, but when calling constructor of WindowResizer – it’s inner member hwndSource = null after initializing… I looked inside and I saw this thing:
window.SourceInitialized += (o, e) => hwndSource = (HwndSource)PresentationSource.FromVisual((Visual)o);
So the event just doesn’t raise and hwndSource = null. Ok I thout I will change event to SourceUpdater, or Loaded – but still that doeesnt work. Can u help me please, cause I’m out of ideas at all. Thanks!
Thanks very much for sharing, that was really helpful on my project :). I think if you have transparent window but opaque border background, you can set RenderOptions.ClearTypeHint=”Enabled” on this border to make ClearType work, no?
Frankly I find it quite frightening that Microsoft supports drop shadows in WPF but not in its current browser!
This helped me during the early hours this morning.
I think I have come up with a cleaner solution that you may be interested in:
http://stackoverflow.com/questions/7369115/maximum-custom-window-loses-drop-shadow-effect
I have a little problem with that. My window is created by costom window style, not like your’s. So I created borders in style and now there’s my problem. Border is created like that:
…
…
In that case I can’t call constructor like you do, cause first I need to get reference to that borders. That references I getting like this:
this.m_TopLeft = (FrameworkElement)this.Template.FindName(“m_TopLeft”, this);
I thought that now I can call the constructor, but there is a small problem – this element are not available when construction of window is performed, so this.m_TopLeft = null.
Hmm I thought ok, then I’ll get those references on window event Loaded. So now I have my needed references to border’s in Loaded event, but when calling constructor of WindowResizer – it’s inner member hwndSource = null after initializing… I looked inside and I saw this thing:
window.SourceInitialized += (o, e) => hwndSource = (HwndSource)PresentationSource.FromVisual((Visual)o);
So the event just doesn’t raise and hwndSource = null. Ok I thout I will change event to SourceUpdater, or Loaded – but still that doeesnt work. Can u help me please, cause I’m out of ideas at all. Thanks!
Good one :)
Wow…it’s very nice …realy thanks
Great article, love it!!!
Very Good Article,it is so helpfull!!!
Thanks very much for sharing, that was really helpful on my project :). I think if you have transparent window but opaque border background, you can set RenderOptions.ClearTypeHint=”Enabled” on this border to make ClearType work, no?