Disable WebBrowser control without opacity in WP7 - windows-phone-7

i've a webbrowser in my application that only have to show without the user. can interact with it.
So if i set the IsEnabled = false, the browser become with a gray opacity on top of page and i don't want this.
How can i do?
Thanks.

If you want to disable user interactions, then you could try:
set IsHitTestVisible to false
or
position an Opacity 0.01 Canvas over the top of the web browser - this would be almost invisible and would stop the user from interacting with it.

To prevent the opacity change on the WebBrowser control when you set IsEnabled to false you will need to create a custom style for it. It's very simple and need only look like the following:
<Style x:Key="WebBrowserStyle1" TargetType="phone:WebBrowser">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="phone:WebBrowser">
<Border x:Name="StateContainer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Opacity="1">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="WebBrowserStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="PresentationContainer"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
However, the user will not be able to interact with the contents. I'm not sure what you are trying to achieve if you want the control to be disabled but interactive. If what you are trying to do is stop the user interacting with the control, then the above would work, or setting IsHitTestVisible to false would achieve the same result, but with fewer changes :P

Related

Prevent diagonal scroll in nested flipview

The code looks like this:
<FlipView>
<FlipViewItem>
<Grid Height="400" Background="Blue"/>
</FlipViewItem>
<FlipViewItem>
<Grid>
<FlipView x:Name="DigestFlipView" Style="{StaticResource DigestViewStyle}"/>
</Grid>
</FlipViewItem>
</FlipView>
And then in my DigestViewStype I have made it vertical as follows:
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</Setter.Value>
What I want is, when swipe is vertical, only inner FlipView should kick in. Also, when swipe is horizontal, only outer FlipView should kick in.
I get the desired behavior if I replace inner FlipView with a ListView. ListView scrolls for vertical swipes and FlipView for horizontal ones. I have tried playing with templates with no luck. Is there a way to achieve what I need with FlipViews?

WP7: Button Tap event does not fire each time

I am having an issue where my button (having an image background) does not fire Tap event each time I tap it on screen (sometimes it fires every time, sometimes once in 3-4 times I tap the button on screen). Project is targeted for WP7.1.
Button is defined in XAML as:
<Button x:Name="Menu" Tap="Menu_Tap" Height="70" Width="70" Margin="0,0,0,0" HorizontalAlignment="Center" Padding="0" VerticalAlignment="Center" Style="{StaticResource MenuImageButtonStyle}"></Button>
Style to define menu background image:
<Style x:Key="MenuImageButtonStyle" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Image x:Name="StartButtonImage" Source="/Images/menu_button.png" Height="33" Width="33" />
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content=""/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Note that I've experimented by using Tap, Click and ManipulationStarted events, but no luck, all events fire erratically.
I am quite sure the issue is not my tapping precision, I make sure to tap at the center of the button. I've tested on Nokia Lumia 800.
Entire project code is available here:
http://notecase.sourceforge.net/temp/wp7Issue.zip
Any idea, why is this so? Any tip to fix this?

Weird behaivior of ProgressBar in WP7

So, I'm tryging to use a progress bar in my WP7 Panorama aplication.
There is one page, that is downloadidng data from the web, so I want to indicate that my App is doing something with ProgressBar
<controls:PanoramaItem Header="news">
<Popup Name="myWeatherPopup" IsOpen="False" Width="404" Height="Auto" Margin="0,136,4,293">
<StackPanel>
<ProgressBar Height="Auto" IsIndeterminate="True" Width="400" />
<TextBlock Text="Loading" HorizontalAlignment="Center" Foreground="Gray" />
</StackPanel>
</Popup>
</controls:PanoramaItem>
It basically works as it should. However, there is one tiny (and anoying bug).
The first... run (?) of the dots appears on every panorama item, just under header. After that, it returns on its normal position under news item.
The same thing happens on emulator and Lumia 800.
Image
Have you tried without the Popup, by just setting the Visibility property on the StackPanel?

WP7 - simplest code to set inputfocus TextBox background, foreground

In Windows Phone 7, I'm looking for simple code to set the background and foreground for a TextBox with inputfocus.
I'm doing this in order to comply with the different themes, and my application visually uses background canvases and other controls which need a standard colorset for controls.
NOTE: Regular foreground, background and borderbrush are fine, and set easily:
<TextBox Background="#BFFFFFFF" BorderBrush="#BFFFFFFF" Foreground="Black"
Canvas.Left="297" Canvas.Top="392" FontSize="20" Height="63" Name="textBox8"
Text="10" Width="126" />
If you want to change the appearance of a control in different states, then you should modify the Style for that control and change the values by using the VisualStateManager as illustrated in the answer to this question: Windows Phone 7 (WP7) Change a button's background color on click
In a similar but slightly different question here on SO, I found a solution, using a Border:
<Border Background="{StaticResource KeyToDesiredBackgroundBrush}">
<TextBlock Text="Forget Password" Height="19" Width="156" />
</Border>
My specific solution ended up being the following:
<TextBlock Canvas.Left="73" Canvas.Top="405" FontWeight="Bold" Foreground="White" Height="30" Name="textInflationLabel" Text="Gasoline Inflation (%):" TextAlignment="Right" Width="224" />
<Border Name="BorderInflation" Background="#BFFFFFFF" Height="45" Width="104" Canvas.Left="308" Canvas.Top="395">
<TextBox Background="#BFFFFFFF" BorderBrush="#BFFFFFFF" Foreground="Black" FontSize="20" Margin="-10,-10,0,0" Height="64" Width="125" Name="tbInflation" Text="12" />
</Border>
Frankly, this seems a little hokey. Hopefully in the future, there are simpler ways to perform such standard tasks.

Windows phone 7 keyboard size

I want to resize the page when the keyboard appears on the screen.
I was looking for any clue all day but I can't find anything.
In my case. I want to have full page TextBox and some buttons under it.
<Grid x:Name="RootLayout" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="70"/>
</Grid.RowDefinitions>
<ScrollViewer Margin="0" >
<TextBox TextWrapping="Wrap" Text="TextBox" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" Height="698" Width="480"/>
</ScrollViewer>
<Canvas x:Name="RootMenu" Margin="0,1,0,0" Grid.Row="1" />
</Grid>
</Grid>
I use to thing that the first row will change its size automatically, but it doesn't happening.
Please help me.
///// -----------------------------------------------------------------------------
I'm going to dislike this OS! Proposed solution is not good at all. When the keyboard is visible then I can not scroll it down.
Lets say I want just simple TextBox to let users write something. But it is impossible !!
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True">
<shell:ApplicationBarIconButton IconUri="/icons/appbar.check.rest.png" Text="aplay"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
<Grid x:Name="RootLayout" >
<ScrollViewer>
<TextBox Text="TextBox" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" />
</ScrollViewer>
</Grid>
There isn't a way to know for sure if the SIP is displayed. Jaime Rodriguez has a post showing how to make a fairly reliable guess of this.
If you want to have "buttons" that are always displayed then the best, and only reliable, way to do this is to use the ApplicationBar.

Resources