任何人都可以帮助链接到综合示例或预订ListView的所有可能类型的列。 ListView绑定到Observable集合但是只读(除了复选框,主要是为应用程序的选定行驱动某些操作)。
答案 0 :(得分:4)
将其粘贴到Kaxaml中:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.Resources>
<XmlDataProvider x:Key="Data">
<x:XData>
<Data xmlns="">
<Item ID="1" Desc="Google" URL="http://www.google.com" Acceptable="true"/>
<Item ID="2" Desc="StackOverflow" URL="http://www.stackoverflow.com" Acceptable="true"/>
<Item ID="3" Desc="4chan" URL="http://www.4chan.org" Acceptable="false"/>
</Data>
</x:XData>
</XmlDataProvider>
</Grid.Resources>
<ListView DataContext="{Binding Source={StaticResource Data}, XPath=/Data}"
ItemsSource="{Binding XPath=Item}">
<ListView.View>
<GridView>
<GridViewColumn Header="ID" DisplayMemberBinding="{Binding XPath=@ID}"/>
<GridViewColumn Header="Description" DisplayMemberBinding="{Binding XPath=@Desc}"/>
<GridViewColumn Header="URL">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock>
<Hyperlink NavigateUri="{Binding XPath=@URL}">
<TextBlock Text="{Binding XPath=@URL}"/>
</Hyperlink>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Acceptable">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding XPath=@Acceptable}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Page>
为了使这个(更多)有用,您需要将其保存为Page.xaml
并创建一个新的XAML文件:
<NavigationWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Source="Page.xaml"/>
否则,单击超链接将转到相关页面,您将保留该页面。
答案 1 :(得分:1)