Layering Image over Flash XAML - c#

I have a flash UI, and a image. I would like to place the image OVER the flash object, but I can't seem to get it working when using Panel.Zindex.
Here is my Code
<my1:WpfFlashUI Name="mFlashUI" Margin="0,0,0,6" HorizontalAlignment="Stretch" Panel.ZIndex="2" />
<Image Name="img2" Source="http://www.donkersct.nl/wordpress/wp-content/uploads/2012/07/stackoverflow.png" Height="217" Width="363" Margin="560,199,-45,6" Panel.ZIndex="1" />
Can anyone see why this isn't working, or suggest a better way? I have tried swapping the Zvalues around.

Related

Pointer events not triggered on UI Elements in custom control

I am creating an application with a UserControl containing multiple UI Elements. The UserControl is rendered into a StackPanel using ItemsControl since the number of UserControls to be rendered depends on user's input.
The basic XAML in the UserControl is as follows.
<Grid x:Name="Viewport" VerticalAlignment="Top" HorizontalAlignment="Center">
<Border x:Name="ViewportBorder" Background="White" BorderThickness="2, 2, 2, 2" BorderBrush="#FF353334" />
<Image x:Name="Image" Margin="0" UseLayoutRounding="True" ManipulationMode="Scale"/>
<InkCanvas x:Name="InkCanvas" />
<Canvas x:Name="SelectionCanvas" CompositeMode="SourceOver" />
</Grid>
I want to change the cursor icon when user is hovering over the SelectionCanvas (based on a condition check in my case as you might see in the source). It seemed pretty straight forward so I tried to use PointerEntered & PointerExited events to capture & release the pointer from the SelectionCanvas. And PointerMoved to change the cursor icon. But it seems that none of the events were triggering.
I tried binding to the Viewport grid element as well but no luck in that too.
I'm not sure what I missed here. Could someone please help me on this? Any help is much appreciated. Please find the complete source code here.
Please note that a sample PDF is included into the startup project /Resources which you'll have to open from the app.
The PointerEntered and PointerExited events are raised provided that the area that is supposed to raise them is painted so try to set the Background property of the Canvas to some brush like for example Transparent:
<Canvas x:Name="SelectionCanvas" CompositeMode="SourceOver"
Background="Transparent"
PointerEntered="SelectionCanvas_PointerEntered"
...

Can't add image to WPF

I trying to add images to my WPF windows but I'm not able to.
What I tried to do is to add Source to the Image Xaml and the image does display on the designer, but when I run the program the image is not displayed
<Image HorizontalAlignment="Left" Height="197" Margin="0,0,0,64"
VerticalAlignment="Bottom" Width="355" Source="pack://siteoforigin:,,,/Resources/Airplane1.jpg"
Grid.ColumnSpan="7"/>
Suppose that you put your image at Resources an it's build action Resource, just try to put :
<Image HorizontalAlignment="Left" Height="197" Margin="0,0,0,64"
VerticalAlignment="Bottom" Width="355" Source="/Resources/Airplane1.jpg"
Grid.ColumnSpan="7"/>
Let me know if it won't work

windows phone 8 show blank map

I am trying to add a simple map to my app.
I added map reference, added capability in WMAppManifest and this code to page:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<maps:Map x:Name="MyMap" Center="47.6097, -122.3331" ZoomLevel="10" HorizontalAlignment="Left" VerticalAlignment="Top" Loaded="Map_Loaded_1" />
</Grid>
but it show blank map. What I mean blank? a black page!
I can not get it to work. tell me what I missed!?
Try to follow this guide step by step, and see if it helps.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207045(v=vs.105).aspx
Maybe your internet connection is dead (or just not configured properly in emulator)?

Access button content (which is an image) through code in Windows Phone

I have a button that features a grid which in turn contains an image.
<Button Style="{StaticResource ButtonStyle1}" d:LayoutOverrides="GridBox" Margin="0,0,0,2.667" BorderThickness="3" BorderBrush="Black" Name="btn1" Click="btn1_Click">
<Grid>
<Image x:Name="img1" Source="Images/Numbers/1.png" Margin="-10,-3,-10,-5" Stretch="Fill"/>
</Grid>
</Button>
I would like to know if there is a way to access the image holder through code without having to explicitly name it as I have above? If I had several buttons and could do it differently it might be easier.
Thanks
yes you can:
var theImage = (Image)((Grid)btn1.Content).Children[0];
you have to make sure though that the button contains a Grid with an Image otherwise you get a cast or null pointer exception.

Focus on Canvas overlapping the listbox in WP7

I have a situation here. I have a page containing a ListBox. The ListBox is populated with Items if it is able to fetch the data from a web service. Now when the user doesn't have network connectivity on his phone or the webservice doesn't respond back with Ok status, I want to show the user a pop-up with an option to Retry or select Ok to stay on the same page (though it sounds dumb). Now for this I used a Canvas:
<Canvas Name="Nonetwork" Height="150" Width="280" HorizontalAlignment="Center" VerticalAlignment="Center" Background="DodgerBlue" Visibility="Collapsed" Margin="111,160,92,160" >
<TextBlock VerticalAlignment="Top" Height="120" Width="280" Text="No Network is currently availabe" TextAlignment="Center" TextWrapping="Wrap" Foreground="White" FontSize="28" />
<Button Margin="30, 80" Height="60" Width="100" Content="OK" FontSize="18" Click="Ok_Click"/>
<Button Margin="150, 80" Height="60" Width="100" Content="Retry" FontSize="18" Click="Retry_Click"/>
</Canvas>
Well as most of you experienced guys would have guessed, the canvas is buried inside the listbox and is not accessible when there is no network connectivity. So I have a blank page with the canvas but the user is not able to click on Ok or Retry. Please help
Please do let me know if there is any other approach to solve this problem. I tried Popup but I cant Navigate to the main page from a pop-up since that is a user control page. Any help is higly appreciated
Well, I placed my Canvas below the ListBox and the problem was solved. I didn't know that positioning of the controls in the XAML would have so much effect ...
The order in which elements are rendered in Silverlight is determined firstly by where they appear in the visual object hierarchy and secondly by their ZIndex property.
The Canvas has a third attached property named ZIndex that you can use to override the default layering of elements. Although this Canvas.ZIndex attached property is defined by the Canvas class, it actually works with any type of panel.
You can also try Canvas.ZIndex property:
Canvas.ZIndex Attached Property
What you do is a wrong practice and not at all recommended.
ChildWindow is the class you should use to display such kind of dialog.
Using a Popup is also another approach you can use.
NOTE: I know the simplest approach would be to use MessageBox.Show(), but it would create a popup out of silverlight frame and does not allow theming/styling and other customizations.

Categories