WPF XAML - Line根本没有出现

时间:2017-02-24 13:35:32

标签: wpf xaml

我制作了一个简单的用户界面,我希望在My playground ***let cell1 = UICollectionViewCell() let cell2 = UICollectionViewCell() let cells = [cell1, cell2] let collection = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) for cell in cells { collection.register(cell, forCellWithReuseIdentifier: "hello") }*** Any ideas? Thanks in advance 行的底部设置边框。我的目的是使用Grid,如此:

Line

我尝试使用纯色而不是我在这里设置的画笔,我确保当我突出显示这条线本身时,高光确实有一个覆盖(它看起来像一个与一条线相对的矩形,所以应该可见)。 请注意,我没有使用<Window x:Class="HP_hf_shop.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:HP_hf_shop" mc:Ignorable="d" Title="MainWindow" Height="500" Width="800" > <Grid> <Grid.RowDefinitions> <RowDefinition Height="2*"/> <RowDefinition Height="10*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="2*"/> <ColumnDefinition Width="2.5*"/> <ColumnDefinition Width="2*"/> </Grid.ColumnDefinitions> <Border Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" VerticalAlignment="Bottom" Margin="10,0,10,0"> <Border.Background> <LinearGradientBrush StartPoint="0,1" EndPoint="1,1"> <GradientStop Color="DarkGray" Offset="0.05"/> <GradientStop Color="Gray" Offset="0.15"/> <GradientStop Color="Gray" Offset="0.85"/> <GradientStop Color="DarkGray" Offset="0.95"/> </LinearGradientBrush> </Border.Background> </Border> <Button Grid.Row="1" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,30,10,10"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="5*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> </Grid> </Button> <Button Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,10,10"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="5*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> </Grid> </Button> <Button Grid.Row="1" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,30,10,10"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="5*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> </Grid> </Button> </Grid> 。该行位于Canvas上,带有一些按钮。任何想法为什么线根本不显示,甚至在运行时都没有显示?

1 个答案:

答案 0 :(得分:1)

  

任何想法为什么线根本不显示,甚至在运行时都不显示?

您需要设置X1的{​​{1}}和X2属性,以绘制水平线:

Line

如果您希望画笔填充网格行,您应该使用另一个伸展的元素来填充可用空间,例如<Line Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" StrokeThickness="10" Margin="10,0,10,0" X1="0" X2="100"> <Line.Stroke> <LinearGradientBrush StartPoint="0,1" EndPoint="1,1"> <GradientStop Color="DarkGray" Offset="0.05"/> <GradientStop Color="Gray" Offset="0.15"/> <GradientStop Color="Gray" Offset="0.85"/> <GradientStop Color="DarkGray" Offset="0.95"/> </LinearGradientBrush> </Line.Stroke> </Line>

Border