Using AdDuplex in a XNA - Silverlight WP7 hybrid application
Provably most of you know AdDuplex to cross-promote WP7 apps and games. That ad engine provides two SDK's, one for XNA games and another for Silverlight apps.
I have a SL-XNA hybrid game, and I can't find the way to make the ads work in such environment. I've been able to render the ad using a Silverlight UIElementRenderer on the XNA graphics environment, but I can't find the way to handle the click on it.
This is how the XAML looks like:
<Grid Name="root" Margin="0,0,0,7000" Width="480" Height="90" Background="Black" > <adduplex:AdControl x:Name="adDuplex" xmlns:adduplex="clr-namespace:AdDuplex;assembly=AdDuplex.AdControl.Silverlight" AppId="10675" /> </Grid>
I've heard that some people has used adDuplex in such environments. Any idea on how to do it? Thanks.
Without seeing the code behind and full XAML I can't say for sure but the clue is in the Margin="0,0,0,7000". My guess is that you are drawing the AdDuplex control in a different location to where it is actually positioned.
If you are initialising the UIElementRender something like this
renderer = new UIElementRenderer(adDuplex, 480, 90);
and drawing like this
renderer.Render(); spriteBatch.Begin(); spriteBatch.Draw(renderer.Texture, Vector2.Zero, Color.White); spriteBatch.End();
then that would explain the problem. Instead, set the Margin="0" on the AdDuplex control (making sure that it is visible on the page) and initialise your UIElementRenderer using the root element on your page. By default this is a Grid called "root" but you may have changed this to something else.
renderer = new UIElementRenderer(root, 480, 800);
The draw code should be same as above. The AdDuplex control should now draw in the same location as the actual control and tapping on it should launch the web browser.
You might want to tweek this solution if you don't want to draw a 480,800 bitmap each frame but at least it will test if it fixes the problem.