InkCanvas stores all the drawing etc in "Strokes" collection and stores all the controls in "Children".
When I draw something then create a TextBox the TextBox remains under the drawing. I can't change its zIndex to bring it forward.
Is there a way to bring the text on top?
InkCanvas is not really meant for content other than strokes. But you could add the TextBox to another Panel that is over the InkCanvas, e.g.:
<Grid>
<InkCanvas/>
<Canvas>
<TextBox/>
</Canvas>
</Grid>
Related
I'm trying to figure out how to overlay an image or textbox over an image in WPF. The base image will be hosting a video feed from a Kinect sensor and I want to overlay an image on it. For example the video feed will have a textbox on the feed that will update a counter or an image of a tree on top of the video feed.
Is there a straightforward way of achieving this in the layout? Is it just a matter of changing properties or adding a canvas?
The below picture better illustrates what it is I'm trying to do:
You can use two transparent canvas inside the Grid without any row and column then place your objects in Back and front Canvas accordingly they will overlap
that is:
<Grid>
<VideoControl><!-- I've never tried video --></VideoControl>
<TextBlock Text="My Text" />
</Grid>
Usually you specify <Grid.ColumnDefinitions> and <Grid.RowDefinitions> but since you do not du that here the controls will overlap
HTH
The usual way for me to overlay items in WPF is just to put all of the elements in a Grid. If you do not define any Columns or Rows the elements will overlap.
Example
<Grid>
<Image Source="image on lowest layer" />
<Image Source="overlaying image" />
</Grid>
I am using a border object in xaml with a large border thickness. However need a way to prevent the contents of the border from shrinking when i increase the border thickness, I just want them to draw over it if they are near enough to the edge. Any ideas?
Don't place your content inside the border, place it "above" it instead:
<Grid>
<Border BorderThickness="20"/>
<OtherContent/>
</Grid>
I'm new to winRT, i'm trying to make a world map app.
I have a canvas control with a lot of path controls in it(every path control represents a country)
Now i want to make something so i can zoom in my canvas, so instead of seeing the wolrd map, i have to focus on, for example, Europe.
I think, it is easy to zoom in an image control, but an image control can't have different path controls in it.
Is there a way to make a zoom behavior or something on a canvas control?
thx in advance
You can try enclosing the canvas inside a ScrollViewer:
<ScrollViewer MinZoomFactor="0.25" >
<Canvas>
<Canvas.Background>
<ImageBrush x:Name="_background" />
</Canvas.Background>
</Canvas>
</ScrollViewer>
...then you can assign an image source to the canvas (in your case, a map).
Assume I have a re-sizable part in UI that is a standard WPF container control (in this case a Canvas) and I put some text on this Canvas. How can I re-size my text according to rendered size of my Canvas?
Viewbox will stretch a TextBlock
How to: Apply Stretch Properties to the Contents of a Viewbox
<Viewbox Grid.Row="1" Grid.Column="1" Name="vb1" Stretch="Fill" >
<TextBlock Text="tulip_farm.jpg"/>
</Viewbox>
You can simply link a method to the container resize event, that will resize the text as well (this way they are always in sync), i would offer an example but since you did not post an example, i think you undetrstand what i mean.
I don't want to display content that is outside the border in my wpf application. Here is an image to illustrate better my point:
in that picture the blue box is the border and note that its child is a listview. I don't want to display the entire listview. I just want to display whatever is inside the blue border.
What control do I have to use in order to achive that? I am looking for some sort of a mask... Is creating a custom user control my only option?
<Border ClipToBounds="True">
<ListView .../>
</Border>
Just set ClipToBounds to true on the border and it should be cut off.