XBAP Gadget

  • Thread starter Thread starter Steven Tang
  • Start date Start date
S

Steven Tang

I'm creating WPF gadget by embed XBAP Iframe:
1. Is it possible that create Pure WPF (non-XBAP) which could
auto dock into the Vista sidebar when dragging the WPF application
near Sidebar?
2. My current approach is using XBAP inside the iFram,
The problem I met in XBAP gadget is that it is difficult to set padding so
that the gadget could be
drag out of the sidebar. I.E., the size of my XBAP is 190X145, my html
launcher is
<html>
<head>
<title>XBAP Gadget</title>

<style>
body {
width:145;
height:190;
padding:0;
margin:0;
background:black;
}
</style>
</head>
<body>
<iframe height="190"
width="145"
src="XbapGadget.xbap" />
</body>
</html>

when it is running, it just dock into the sidebar and the drag handle will
not show up no matter cursor move to anywhere on the gadget. I tried
change the padding or margin, the drag handle did show up, but the
untransparentable background make the gadget pretty ugly.

Any hints to make an ideal WPF gadget?

Best Regards
Steven
 
Hello,

Welcome to Microsoft Newsgroup Support Service! My name is Marco Zhou. It's
my pleasure to work with you on this thread.

For your first question, the simple answer is no, there is an option to
wrap WPF content inside a Windows Forms UserControl, and expose this
UserControl as ActiveX control so that it could be consumable by HTML
container (aka sidebar container), but this is not a pure WPF solution. I
think you will be more successful if you choose Silverlight rather than WPF
because Silverlight provides much better and integrated support in HTML
interop.

For your second question, I don't fully understand which issue you are
referring to, in particular what you mean by "drag out of the sidebar". If
you mean that the hosted XBAP content cannot be stretched to fill its
available space as its neighboring HTML content does, then this is a known
issue.

When hosting WPF content in native container such as Windows Vista sidebar
container, due to the fact that WPF uses device independent pixels, but the
native HTML container use physical pixels, so both of WPF content and
native HTML content will be stretched up and down unequally. One simple fix
is to use System.Windows.Controls.Viewbox control to wrap the root element
of WPF content, so that the content can be stretched out as it is.

If you have any further questions on this issue, free feel to ask here, we
are glad to answer them.

--------------------------------------------------
Best regards,
Macro Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Marco,
Thank you very much for answering my question. The reason that I didn't
use
Silverlight is that my gadget will talk to non-clr version native DLL to
retrieve
some video data, and SL doesn't support this. Am I right?
The issue I mentioned before was that the Gadget would just dock inside
the sidebar
and it could not draggable by using padding = 0 and margin = 0, If I adjust
the padding or/and margin value bigger than 0, there will be a border with
the gadget where could show drag handle, but the border is not transparent
and it ruins the
visual of the Gadget.
<style>
body {
width:145;
height:190;
padding:0;
margin:0;
background:black;
}

If using Viewbox control to wrap the root of WPF content, will the
Gadget still
draggable and without visual ruined? Could you explain more detail on how to
do this?

All the best.
--
=======================
Steven Tang
SYWWUYU)
**:)
 
Hi Steven,

I would greatly appreciate if you could provide a small ,complete and
ready-to-run example to demonstrate the layout issue you described above,
since I cannot reproduce this issue.

You could send your minimalist project to me at v-mazho at microsoft dot
com.
--------------------------------------------------
Best regards,
Macro Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Macro, I sent the mail to you, the title is
"Following XBAP Gadget in General Discussions".

All the best
 
Hi Steven,

Based on my personal research, you need to set the margin or padding of the
HTML root element, the reason is as follows:
Vista sidebar Gadget will typically show the "drag indicator" only if you
are mouse over HTML based content, the XBAP content is actually hosted
inside an ActiveX which has its own mechanism of hit testing and mouse
handling, which means Vista sidebar Gadget container cannot show the "drag
indicator" when you mouse over the XBAP content, this is expected, because
you do want the mouse events to get routed and processed by the XBAP rather
than the sidebar container. So if you don't set the margin or padding of
the HTML body element, the XBAP content will completely fill the whole area
of the HTML body element.

But setting the margin and padding will leave a portion of space colored
differently from the hosted XBAP application's background which is not
aesthetically pleasing. In order to let the gadget looks good, I recommend
you to layout the HTML and XBAP content as follows:

<html>
<head>
<title>XeePet Gadget</title>
<style type="text/css">
body
{
width: 130;
height: 140;
padding: 0;
margin:0;
}
</style>
</head>
<body background="Frame.png">
<iframe width="128" height="140" src="XbapGadget.xbap" />
</body>
</html>

You can see that both the XBAP background and the background of the HTML
root element is set to the same background image, and I leave a 2X140 strip
at the right hand side of the gadget, I think people will not pay too much
attention to this 2X140 strip which is stretched a little bit different
from the rest of gadget because the background is the same. So that when
you mouse over this strip, Vista's sidebar container knows that you are
hovering over the HTML based content, and the "drag indicator" should be
displayed as it is.

I hope the solution above works for you. If you have any further questions
on this issue, free feel to ask here, we are glad to answer them.

--------------------------------------------------
Best regards,
Macro Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hello Marco,
Didn't get your response for pretty long time, did you receive my
email? shall I follow up in this thread instead of email?

All the best
--
=======================
Steven Tang
SYWWUYU)
**:)
 
Back
Top