Name attribute missing

Jul 21, 2009 at 1:52 PM

I'm trying to use essential window. And I need Name attribute. Any workaround?

Jul 22, 2009 at 2:42 AM

I've sorted it out. Another issue i had is if you host winforms control it clashes with AllowsTransparency=true. It took me immense amount of time to figure it out. So remove AllowsTransparency attribute (or set it to false) and set WindowStyle="None" to remove standard ugly window frame.

Aug 1, 2009 at 1:21 PM

Hello, Band,

If you care to say anything about how you went about hosting a WinForms Control, that would be very appreciated.

best, Bill

Aug 2, 2009 at 5:12 AM

hosting itself is standard approach you can find it anywhere.

e.g. i did it this way. i created win form user control MyUserControl (with other win form controls on it).

then wherever you want it in Window1.xaml

<Grid>
      <WindowsFormsHost x:Name="WinFormHost1" />
</Grid>

and in wpf window

public partial class Window1 : EssentialWindow
{
        private MyUserControl uc = new MyUserControl();

        public Window1()
        {
            InitializeComponent();

            WinFormHost1.Child = uc;
        }

...

}

but the trick is with AllowsTransparency=true. in this case winform control does exist but always at the back in z-order and there is no way to see it unless you remove AllowsTransparency (or set it to false). but if you do it you'll see standard window frame which we don't want to see (we have nicely looking frame created by this library). so set WindowStyle=none. So the result will be achieved except less than 1 millimeter thick grey outer border left from standard window. but i can live with that.

Aug 2, 2009 at 7:50 AM

Hi Band,

Thanks for taking the time to reply !

I am familiar with hosting in general, thanks.

When I read : "I've sorted it out. Another issue i had is if you host winforms control it clashes with AllowsTransparency=true. It took me immense amount of time to figure it out. So remove AllowsTransparency attribute (or set it to false) and set WindowStyle="None" to remove standard ugly window frame." ...

I thought you might have actually been able to "go further," and get an imported WinForm/UserControl or whatever actually working/visible with AllowTransparency set to "True" :)

I have been using the "Essential Window" as a kind of "training wheels" (I'm relatively new to WPF, but an "old hand" in C# and WinForms).

In my reading (McDonald's book, Sells' Book, Adam's book), I've read several times about how an imported WinForms whatever will be at the top of the z-order, and I have read about "airspace" issues ... although I'm not sure I totally grok them yet :)

Right now, as an experiment, I have a very complex 3rd. party (commercial, TreeView) WinForms control being hosted in a WindowsFormsHost in a modified "Essential Window" : interetingly : when AllowTransparency is set to "true" : at runtime : even though you can't "see" the control, I can get a hit off the TreeNodes !

I really like the looks you can get with the "Essential Window" flavor of CustomWindowControl, but I guess it's "set in stone" that a WinForm cannot be used with transparency.

best, Bill

dotScience

Chiang Mai, Thailand