Disable WebBrowser control without opacity in WP7
i've a webbrowser in my application tha开发者_Python百科t 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
精彩评论