This project is read-only.

Making gridview cell editable.

Oct 8, 2010 at 11:21 AM

Hello,

Referring the FamilyData control, I tried creating a editable grid view CellTemplate. Please see the code below.  The data is getting displayed in the grid but when I click the cell its not displaying the textbox.

Please anyone tell me wahats wrong with this code.

<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="Window1" Height="279" Width="672">

<Window.Resources>
<Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}" >
<Setter Property="Background" Value="#00ffffff" />
<Setter Property="BorderBrush" Value="#00ffffff" />
<Setter Property="AcceptsReturn" Value="False" />
<Setter Property="AcceptsTab" Value="False" />
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="Foreground" Value="#ff000000" />
<Setter Property="BorderBrush" Value="#ff000000" />
<Setter Property="Background" Value="#a0ffffff" />
</Trigger>
</Style.Triggers>
</Style>

<DataTemplate x:Key="TextColumnTemplate">
<TextBox Style="{StaticResource TextBoxStyle}" Text="{Binding DayOfWeek}" />
</DataTemplate>
</Window.Resources>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.Column="0">
<ListView x:Name="DateList" Background="{x:Null}" Margin="0,5,0,0" BorderBrush="{x:Null}"
ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"
VirtualizingStackPanel.IsVirtualizing="True" ScrollViewer.CanContentScroll="True"
SelectionMode="Single">
<ListView.View>
<GridView >
<GridViewColumn Width="120" Header="Date" />
<GridViewColumn Width="120" Header="Day Of Week"
DisplayMemberBinding="{Binding DayOfWeek}" CellTemplate="{StaticResource TextColumnTemplate}"/>
<GridViewColumn Width="120" Header="Year"
DisplayMemberBinding="{Binding Year}" />
</GridView>
</ListView.View>
<sys:DateTime>1/2/3</sys:DateTime>
<sys:DateTime>4/5/6</sys:DateTime>
<sys:DateTime>7/8/9</sys:DateTime>
<sys:DateTime>10/11/12</sys:DateTime>
</ListView>
</Border>
</Grid>
</Window>