我有一个列表视图,第一列组件是单选按钮,第三列是文本框。第二列只是一个标签。所有这些我都工作得很好。
问题是,我希望最后一行不一样。我只希望第二列是一个文本框,而不是一个标签。ListView的内容与XmlDataProvider绑定。
这里是xmldataprovider:
<XmlDataProvider x:Key="Properties" XPath="/Info">
<x:XData>
<Info xmlns="">
<Property Name="Text" Value=""/>
<Property Name="Tooltip" Value=""/>
<Property Name="Enable" Value=""/>
<Property Name="Visible" Value=""/>
<Property Name="Focus" Value=""/>
<Property Name="Selected" Value=""/>
<Property Name="Count" Value=""/>
<Property Name="Item" Value=""/>
<Property Name="SelectedText" Value=""/>
<Property Name="SelectedIndex" Value=""/>
<Property Name="Complete" Value=""/>
<Property Name="Custom" Value=""/>
</Info>
</x:XData>
</XmlDataProvider>
以及ListView定义:
<ListView Name="lstProperties" Margin="55 0 0 0" Style="{DynamicResource TsListView}"
Grid.Row="2" Grid.RowSpan="7" Grid.ColumnSpan="4"
ItemsSource="{Binding Source={StaticResource Properties}, XPath=Property}"
ItemContainerStyle="{DynamicResource TsListViewItem}"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
SelectionMode="Single" IsEnabled="False"
SelectionChanged="propertySelected"
>
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn CellTemplate="{StaticResource FirstCell}" Width="25" />
<GridViewColumn Header="Property" Width="80">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label Style="{DynamicResource TsLabel}" Height="25" Width="115" Content="{Binding XPath=@Name}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Value" Width="130">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Style="{DynamicResource TsHelperTextBox}"
Height="20" Width="115" Text="{Binding XPath=@Value}"
IsEnabled="{Binding ElementName=rbTypeAssert, Path=IsChecked}" GotFocus="gridTextBox_GotFocus" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
我希望自定义属性显示在文本框中,而不是标签中。
谢谢你的帮助!