Exceptions in ListView rows
I have a ListView with the first column components being RadioButtons and the third column being TextBoxs. The second column is just a Label. I have all this working fine. The problem is that I want the last row to be different. All I wanted was the second column to be a TextBox instead of a label. The content of the listview is binded with a XmlDataProvider.
Here it is the 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>
And the ListView definition:
<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>
I wanted the Property Custom to be presented in a TextBox instead of a Label.
Thanks for any help!
I got an answer that works just fine at the MSDN Forums.
精彩评论