我正在构建一个UWP应用程序,我的ListView有问题。我想从ListView中的TextBlock更改ColumnSpan。
<ListView Grid.Row="1" BorderBrush="#0062AD" BorderThickness="1" ItemsSource="{Binding BusRoutes}" x:Name="Routes1" SelectionMode="None" IsItemClickEnabled="False" Padding="0 10 0 0">
<ListView.ItemTemplate>
<DataTemplate>
<Grid Width="400">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="startingPoint" Grid.Row="0" Grid.Column="0" Padding="0 10 0 10" TextAlignment="Center" HorizontalAlignment="Center" Text="{Binding hours}"/>
<TextBlock TextAlignment="Center" Grid.Row="0" Grid.Column="1" Padding="0 10 0 10" x:Name="endingPoint" HorizontalAlignment="Center" Text="{Binding hours2}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
我的意思是我想设置名为startingPoint ColumnSpan = 2的TextBlox并以编程方式将名称为endsPoint的TextBlock设置为Collapsed。这可能吗?
答案 0 :(得分:0)
是的,您可以使用以下命令更改列范围并以编程方式设置可见性:
endingPoint.Visibility = Visibility.Collapsed; //to make it invisible
Grid.SetColumnSpan(startingPoint, 2); //to change it the 2 column span
希望它有所帮助。