<Window x:Class="TabInListView.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
Height="350"
Width="555"
Loaded="Window_Loaded">
<Grid>
<ListView Name="lstDemo" KeyboardNavigation.TabNavigation="Continue">
<ListView.ItemContainerStyle>
<Style>
<Setter Property="KeyboardNavigation.IsTabStop" Value="False" />
</Style>
</ListView.ItemContainerStyle>
<ListView.View>
<GridView>
<GridViewColumn Header="Column1" Width="100" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Width="100" HorizontalAlignment="Stretch" Text="{Binding Path=Column1}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Column2" Width="100" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Width="100" HorizontalAlignment="Stretch" Text="{Binding Path=Column2}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Column3" Width="100" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Width="100" HorizontalAlignment="Stretch" Text="{Binding Path=Column3}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Column4" Width="100" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Width="100" HorizontalAlignment="Stretch" Text="{Binding Path=Column4}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Column5" Width="100" >
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox Width="100" HorizontalAlignment="Stretch" Text="{Binding Path=Column5}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
******************************************************************************
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
namespace TabInListView
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
try
{
List<Test> lst = new List<Test>();
lst.Add(new Test { Column1="",Column2="",Column3="",Column4="",Column5=""});
lst.Add(new Test { Column1 = "", Column2 = "", Column3 = "", Column4 = "", Column5 = "" });
lst.Add(new Test { Column1 = "", Column2 = "", Column3 = "", Column4 = "", Column5 = "" });
lst.Add(new Test { Column1 = "", Column2 = "", Column3 = "", Column4 = "", Column5 = "" });
lst.Add(new Test { Column1 = "", Column2 = "", Column3 = "", Column4 = "", Column5 = "" });
lst.Add(new Test { Column1 = "", Column2 = "", Column3 = "", Column4 = "", Column5 = "" });
lst.Add(new Test { Column1 = "", Column2 = "", Column3 = "", Column4 = "", Column5 = "" });
this.lstDemo.ItemsSource = lst;
}
catch (Exception)
{
throw;
}
}
private class Test
{
public String Column1 { get; set; }
public String Column2 { get; set; }
public String Column3 { get; set; }
public String Column4 { get; set; }
public String Column5 { get; set; }
}
}
}
******************************************************************************
No comments:
Post a Comment