sMike54 sMike54 - 1 month ago 19
C# Question

Windows Phone 8 XAML- How to create Line?

I have this:

enter image description here

with this code:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource MenuButton}"
Content="Zapnout senzory"/>
</StackPanel>
<Rectangle Fill="Black" Height="2"/>
</StackPanel>
</Grid>


and I'd like to use Line instead of the Rectangle, but when i write this:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource MenuButton}"
Content="Zapnout senzory"/>
</StackPanel>
<Line Fill="Black" Stroke="Black"
Height="2" StrokeThickness="5"/>
</StackPanel>
</Grid>


there is no line. Any ideas how to do it?

And in next part of the app, I'd like to have this:

enter image description here

line next to the button and I dont have idea how to do it.
I want to use this app on different displays, so it has to be relative.

Answer

You have to use a <canvas/> control in your stackpanel, if you want to define the exact position (in the canvas) for the line.

If you just want to add a "break" line in your stackpanel, use a rectangle with Width="xyz" and Height="1"

HTH