Border for WebBrowser control - c#

First i have created a web browser control(full screen sized) and then i have created a border above the web browser control but when i debugged it, the border is not visible. Need help? Thanks in advance for your hard work!
<Border x:Name="UrlBorder" Background="{StaticResource PhoneAccentBrush}" CornerRadius="8">
<TextBox x:Name="UrlTextBox" Background="White" InputScope="URL" Margin="0,0,98,0"/>
</Border>
<phone:WebBrowser x:Name="BrowserHost" Margin="0,12,0,0" Grid.RowSpan="2" GotFocus="BrowserHost_GotFocus" IsScriptEnabled="True" />

Not sure what you are trying to do here. Looks like you want an url input textbox surrounded by border on top of a nearly-fullscreen web browser element. If so, I would use a stackpanel.
<StackPanel>
<Border><TextBox /></Border>
<WebBrowser/>
</StackPanel>
If you want to hide the url input, you can still set the Border's visibility to Collapsed.
Elements in grid can overlap each other. So, the webbrowser element will cover your bordered textbox if it's fullscreen. Also, neither your border, nor your textbox has explicit height nor width.

Related

How to prevent image control from being "selectable" / show selection border?

I have 2 images in a Gridview, and when I run my app the images have a border around them when I mouseover. (see behaviour ->)
Behaviour
Can this be disabled, I've tried all the settings which seem related, such as:
Image x:Name="image1" Height="67" Width="67"
Source="ms-appx:///Assets/logo67.png"
HorizontalAlignment="Right"
IsDoubleTapEnabled="False"
IsHoldingEnabled="False"
IsRightTapEnabled="False"
IsTapEnabled="False"
ManipulationMode="None"/
You need to edit the GridViewItem template, which have default value here https://msdn.microsoft.com/en-us/library/windows/apps/mt299127.aspx
Create a custom style and apply it using ItemContainerStyle property of GridView

How to set button in side stackpanel to right edge in windows 10 universal app development

I an new to windows app development,i searched for this but not found any where.I need the button at right edge and Stretch the textbox till buttons start.But I am unable to set the button to Right edge.
How to acheve this.
A stackpanel works like a container. If you define layout properties on your stackpanel, then the objects inside your stackpanel cannot be displayed outside of the stackpanel's limits.
For example :
If I set my row and column number in my stackpanel,
<StackPanel Grid.Row="0" Grid.Column="2" Name="Version" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Top">
<Label Grid.Column="4" Grid.Row="6" Name="Ver" Content="V." HorizontalAlignment="Right" />
<TextBlock Name="Vers" Text="1.0" TextAlignment="Right" />
</StackPanel>
Then the row/column properties set on my label are ignored and the 'HorizontalAlignment="Right"' will place my label on the right side of the stackpanel, not the grid.
A solution may be to remove your button from your stackpanel, you are then free to place your button anywhere on the grid.
Another solution can be to expand your stackpanel's limits.
To do so, you can use the Grid.ColumnSpan property or simply set your stackpanel on the right of the grid.
Hope that helped.

Most simple FrameworkElement to handle HorizontalAlignment and VerticalAlignment?

This is Silverlight.
Initial goal is to display a random element in a Popup with some VerticalAlignment and HorizontalAlignment. I do not want to use VerticalOffset or HorizontalOffset, because there is more to what I really want to do, including some complex bindings.
First attempt was:
<Popup>
<Button
Height="135"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom" />
</Popup>
Second attempt was:
<Popup
Height="135"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom">
<Button />
</Popup>
Both were a failure: the Button was always on Top and not Stretch (HorizontalAlignment and VerticalAlignment didn't work).
So I had the idea to encapsulate the element in a simple FrameworkElement:
<Popup>
<Border>
<Button
Height="135"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom" />
</Border>
</Popup>
And it is working.
But I had to use Border in this example, when I could have done it with Grid and many other FrameworkElement (but not with Canvas or Viewbox or Popup). I'd like to know what is the most simple, efficient and processor-friendly transparent FrameworkElement to encapsulate another element with working HorizontalAlignment and VerticalAlignment? Is it:
Border? (like the above example)
UserControl?
ContentControl?
ContentContainer?
some custom and basic MyFrameworkElement? (might need help for most basic implementation)
something else like Grid?
WPF controls come in two flavors: Ones that interact with users (like accept user clicks like a button, or display text like a text block) and containers that control placement and layout of the previous ones.
Container controls are usually designed to lay out their children in a specific manner. For example, Canvases lay out children by X, Y, Width & Height values. Each one has a specific use, so you must read the documentation or tutorials for these container controls and understand how each works in order to select the appropriate one for a task.
In your case, you want the button to fill all available space in the popup (it seems, it isn't that clear). I know that the Grid does this by default. So I would do the following:
<Popup><Grid><Button /></Grid></Popup>

How to hide part of text in a richtextbox or textbox using WPF?

i would like to ask for a a way in wpf of hiding and unhiding some specific lines in a richtextbox or textbox using C# at Runtime and at the same time leave the rest of the lines visible. I would also like not to be a visible space between the visible and unvisible lines. i have an idea of selecting the lines and then change font size to 0.01, but it isnt so much elegand.
thanks in advance.
By default, you can only hide and show certain text in a WPF TextBox or RichTextBox by changing the value of the Text or RichText properties respectively. For example if you have the text "Mary had a little lamb who's fleece was white as snow" and wanted to hide the text "who's fleece was white as snow" conditonaly you would have to parse the text and remove or add "who's fleece was white as snow" in the correct location in the Text or RichText using code.
It sounds like you are just trying to modify the layout depending on certain conditions though. In that case, it is better to split the lines up into separate TextBoxes and set the visibility of those textboxes to Collapsed when certain conditions exist and set them to Visible otherwise.
If you are using TextBox you will want an outer Border which will help you match the style of TextBox, then you can set the BorderBrush and Background of the textboxes you are hiding to Transparent so it just looks like a single TextBox.
<Border
BorderThickness="1"
BorderBrush="Black"
Background="White">
<StackPanel>
<TextBox
Text="Mary had a little lamb "
BorderBrush="Transparent"
Background="Transparent" />
<!-- Set the Visisibility Property of this TextBox in code to show or hide it -->
<TextBox
Name="ConditionalTextBoxLine"
Visibility="Visible"
Text="Who's fleece was white as snow"
BorderBrush="Transparent"
Background="Transparent" />
</StackPanel>
</Border>

Bing Maps (Silverlight) maps - specifying canvas to be at foreground through XAML

Below is the XAML code i have for a Bing Maps Silverlight weather related implementation.
Here is what i am trying to do:
Have a bing maps with several (over 100) pushpins- on mouseover - show a contentpopup (canvas=myPopup) below. Simple enough.
Everything works fine - however, when mypopup displays on mouseover, it is not on the foreground (the other pins appear on top of the contentpopup) - hence making it not very readable.
Question:
How do i specifiy the myPopup canvas specified in XAML below to always appear in the foreground, i.e. top most of the Bing Maps silverlight control when a user views it on mouseover.
Thanks!
<Grid x:Name="LayoutRoot" Background="White">
<m:Map x:Name="GlobalMap" Mode="Road" Center="15,7" ZoomLevel="2" CredentialsProvider="{StaticResource MyCredentials}" Margin="-70,-40,-100,-72">
<m:MapLayer x:Name="myLayer">
<Canvas x:Name="myPopup" Visibility="Collapsed" Opacity="1">
<Rectangle x:Name="myPopupRectangle" Fill="White" Canvas.Left="0" Canvas.Top="0" Height="100"
Width="100" RadiusX="15" RadiusY="15"/>
<StackPanel Canvas.Left="8" Canvas.Top="8">
<TextBlock x:Name="myPopupTexts" FontSize="5" Width="100">
</TextBlock>
</StackPanel>
</Canvas>
</m:MapLayer>
</m:Map>
</Grid>
Try adding Canvas.ZIndex to the MapLayer element, give it a large value like 200 or add your push pins to another MapLayer (rather than adding the pins directly to the map) that appears ahead of this popup layer in document order.
I did something similar to this, but took a different approach. What I did was create a custom pushpin template and create a PopUp within the template.
When the user hovers over the pushpin, the popup is displayed. Using the PopUp will solve your problem, since the control will automatically position it on top of everything. Try wrapping the Canvas in a PopPup and see if that works.
hth

Categories

Resources