网格列边框UWP

时间:2016-01-15 09:29:22

标签: c# xaml uwp windows-10-universal

我有以下代码:

<ListView x:Name="lstSync" Margin="0,240,0,110" ItemsSource="{x:Bind Path=ViewModel.SyncItems}" ItemClick="gridViewAll_ItemClick" IsItemClickEnabled="True" SelectionMode="None">
    <ListView.Resources>
        <mAppV2:BoolConverter x:Key="Converter1"/>
    </ListView.Resources>
    <ListView.ItemTemplate>
        <DataTemplate x:DataType="mAppV2:SyncItem">
            <Grid Height="50" Background="White" Margin="0" HorizontalAlignment="Stretch" BorderBrush="#FF2E8FDD" BorderThickness="0,0,0,1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="50" />
                </Grid.ColumnDefinitions>
                <TextBlock Text="{x:Bind name}" FontSize="11" Grid.Column="0" x:Phase="1" Margin="5" VerticalAlignment="Center" Foreground="#FF044071"/>
                <CheckBox IsChecked="{Binding isChecked, Mode=TwoWay, Converter={StaticResource Converter1}}" Grid.Column="1" Margin="4" VerticalAlignment="Center" Width="45" Height="45" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked">
                    <ContentControl>
                        <Image Source="Assets/unchecked_checkbox.png"/>
                    </ContentControl>
                </CheckBox>
            </Grid>
        </DataTemplate>
    </ListView.ItemTemplate>
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListViewItem">
                        <ListViewItemPresenter ContentMargin="0" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </ListView.ItemContainerStyle>
</ListView>

我的问题是我想在Grid中的TextBlock右边有一个边框,但是TextBlock没有Border Property。

有人知道如何实现这个目标吗? 谢谢。

1 个答案:

答案 0 :(得分:8)

是的,TextBlock没有Border属性。您必须使用Border控件,如:

<Border BorderThickness="1">
    <TextBlock Text="abc" />
</Border>

它与WPF中的相同。这是一个教程:http://www.wpf-tutorial.com/misc-controls/the-border-control/