tags:

views:

351

answers:

2

Could anyone help with a link to comprehensive example or book with all possible kinds of columns for ListView. ListView is bound to Observable collection but read-only ( except checkboxes which are primarily to drive certain actions for selected rows for the application ).

+1  A: 

Paste this into Kaxaml:

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
  <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>

To make this (more) useful, you'll want to save it as Page.xaml and create a new XAML file:

<NavigationWindow
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   Source="Page.xaml"/>

Otherwise, clicking on a hyperlink will take you to the page in question, where you will remain.

Robert Rossney