Windows Phone WebBrowser Control Not Rotating, Height Not 100% - c#

I'm building my first simple Windows Phone app. I'm having some trouble though.
I'm using a WebBrowser control to show a web page that I don't have control over. For some reason, the control doesn't rotate with the phone. I'm completely at a loss as to why.
I can't get the height to be 100% of the phone. If I set it to auto, I think it's getting executed as 0.
Can anyone help me with this?

Here's the XAML for a very simple app that only contains a WebBrowser control. It is full size and rotates. Can you compare with your app and spot what's different? BTW, the only attribute I changed on the elements was the value of #SupportedOrientations.
<phone:PhoneApplicationPage
x:Class="WP7WebBrowser.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<Grid x:Name="LayoutRoot" Background="Transparent">
<phone:WebBrowser Source="http://www.bing.com"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
</Grid>
</phone:PhoneApplicationPage>
Hope that puts you on the right path!

Related

Zoombox from Xceed WPF Toolkit not working

I am experimenting with the Zoombox control from Xceed, but I am having trouble getting it to respond to mouse wheel or pan events. Nothing happens when I use these inputs. Am I missing something in my code or configuration?
https://github.com/xceedsoftware/wpftoolkit
<Window x:Class="UI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="MainWindow" Height="800" Width="700">
<Grid>
<xctk:Zoombox MinScale="0.5" MaxScale="100" >
<Grid Width="600" Height="400" Background="Yellow">
<Ellipse Fill="Blue" />
</Grid>
</xctk:Zoombox>
</Grid>
</Window>
You have to define DragModifiers and ZoomModifiers. Default values are Ctrl and Shift keys. So use the combination Shift+MouseWheel for zooming and use Ctrl+LeftButton for panning.

Exception occured on intalizied object in window phone 8 application

I'm not authorized to upload error image on stackoverflow. You can see this error image on this link
http://s24.postimg.org/5lduiutqd/error.jpg
I'm creating Facebook menu in window phone 8 on it's showing compile time error.Basically i'm using user control where create a Facebook menu and call it to mainframe.xaml...
User Control Code
<UserControl x:Class="test.UserControls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:library="clr-namespace:SlideView.Library;assembly=SlideView.Library"
mc:Ignorable="d"
shell:SystemTray.IsVisible="False"
>
<Grid x:Name="LayoutRoot" Grid.Row="0">
<library:SlideApplicationFrame Header="Test App" Background="White">
<library:SlideApplicationFrame.LeftContent>
<TextBox Name="ss" Width="200"></TextBox>
</library:SlideApplicationFrame.LeftContent>
<library:SlideApplicationFrame.RightContent>
<TextBox Name="sss" Width="200"></TextBox>
</library:SlideApplicationFrame.RightContent>
</library:SlideApplicationFrame>
</Grid>
Mainframe.xaml code
<phone:PhoneApplicationPage
x:Class="test.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:local="clr-namespace:test"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<local:UserControls Name="SSS">
</local:UserControls>
</Grid>
</phone:PhoneApplicationPage>

C# Wpf surfaceusercontrol Contact Events not firing

I have a SurfaceWindow. In it is a Scatterview with a ScatterViewItem and in the Scatterviewitem is a viewbox which contains the SurfaceUserControl. I added some ContactEvents to the control like ContactDown, Contactup, ContactTapGesture, etc (and the Preview versions of the events).
The only events fired are contactdown and leave. On the Scatterviewitem the other events work too.
Someone know why?
Sorry that i cant show you any code. I'm on work and for some reason the proxy is blocking the login to this site. I'm writing this with my phone.
<s:SurfaceWindow x:Class="WeltkarteSurface.SurfaceWindow1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.microsoft.com/surface/2008"
xmlns:uc="clr-namespace:WeltkarteSurface"
Title="WeltkarteSurface" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="768" Width="1024" SizeToContent="Manual" Loaded="SurfaceWindow_Loaded" >
<s:SurfaceWindow.Resources>
</s:SurfaceWindow.Resources>
<Grid>
<s:ScatterView x:Name="MainScatterView" Background="#FFB4DCFC">
<s:ScatterViewItem x:Name="MainScatterViewItem" MinWidth="1024" MinHeight="768" Center="512,384" CanRotate="False" Width="1024" Height="768" Background="Transparent" ScatterManipulationDelta="MainScatterViewItem_ScatterManipulationDelta" >
<s:ScatterViewItem.Template>
<ControlTemplate>
<Viewbox x:Name="MainViewbox">
<uc:MainMap PreviewContactTapGesture="MainMap_PreviewContactTapGesture" ContactTapGesture="MainMap_ContactTapGesture"></uc:MainMap>
</Viewbox>
</ControlTemplate>
</s:ScatterViewItem.Template>
</s:ScatterViewItem>
</s:ScatterView>
</Grid>
</s:SurfaceWindow>
This is my Surfacewindow Code. The PreviewContactTapGesture and ContactTapGesture events on MainMap work only if they arent in the Scatterviewitem.
Thanks

Setting child height or width to parent control same as "match_parent" in android

I have a page which includes a grid and within that grid there is a map. But I'm not able to set the size of map same as grid size. Though I can set it in code as
MyMap.Height = LayoutRoot.ActualHeight;
MyMap.Width = LayoutRoot.ActualWidth;
But how can I set it in xaml.
<phone:PhoneApplicationPage
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:maps="clr-namespace:Microsoft.Phone.Maps.Controls;assembly=Microsoft.Phone.Maps"
x:Class="MapSample.MainPage"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<Grid x:Name="LayoutRoot" Background="Red">
<maps:Map x:Name="MyMap" HorizontalAlignment="Left" VerticalAlignment="Top" Center="47.6097, -122.3331" ZoomLevel="10"/>
</Grid>
</phone:PhoneApplicationPage>
You should set the HorizontalAlignment and VerticalAlignmentof the map control to Stretch
<maps:Map x:Name="MyMap"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Center="47.6097, -122.3331"
ZoomLevel="10" />

Adding portrait child element to landscape page

I'm developing a WP7 app in silverlight. I almost done but, I need to insert new user-control in portrait view as a child element of landscape root page.
Each child element (excluding this) is in landscape mode and it can't be changed.
When I change SupportedOrientation to PortrailorLandscape in RootPage and toggle orientation in emulator to portrait then every child element, that was in landscape, is cutted.
This is what I did:
Page root code:
<phone:PhoneApplicationPage
x:Class="app.Root"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Landscape" Orientation="LandscapeLeft"
mc:Ignorable="d" d:DesignHeight="480" d:DesignWidth="800" shell:SystemTray.IsVisible="False">
<Grid Width="800" Height="480" Loaded="RootGrid_Loaded">
<Popup x:Name="myPopup">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="480"/>
</Grid.RowDefinitions>
<Border x:Name="popupBorder"/>
</Grid>
</Popup>
<Canvas x:Name="ScreenRoot"
Visibility="Visible"
Width="800" Height="480">
<Canvas.Children/>
</Canvas>
</Grid>
</phone:PhoneApplicationPage>
Then user-control as a child of ScreenRoot:
<UserControl
x:Class="app.Settings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource OCRAExt}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="WhiteSmoke"
mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
shell:SystemTray.IsVisible="False">
<Grid x:Name="SettingsRoot" Background="Black" Width="480" Height="800">
...
...
</Grid>
</UserControl>
User control listens his state in state machine and then add itself as a Child to Canvas of RootPage.
Please help me:)
I'm not sure to understand what you really want to do, but you can try to apply a RenderTransform to your UserControl, in order to keep it in portrait mode.
http://msdn.microsoft.com/en-us/library/ms754009.aspx

Categories

Resources