Hi,
When I add a new record to my grid, that record is not selectable again, yet the records that were filled upon loading the grid are selectable. There is a protected property call IsSelectable. My old records return true for this property, but my new records return false after I have added the record. Specifically, when the RecordUpdating event is fired the rnew ecord is selectable, when the RecordUpdated event is fired that record is no longer selectable (the property returns false). The documentation is quite sparse for this property, "Returns true only if the record can be selected" is the extent of the documentation. What determines the selectabiity of a record? Why would the initial records be selectable but the added records not be?
Thanks for your help!
TJ
Hi TJ,
Thanks for providing the code. We've been able to create a sample out of it and debug it. The reason you are not able to select the added records is because in the sample, in dgControls_InitializeTemplateAddRecord, you are setting their Enabled to false. This will make the record non-editable as well as non-selectable.
Hope this helps,
Sandip
Joe,
I tried to eliminate any extraneous code. The current behavior is once I add a new row and select out of it, I can never select it again. Below is the XAML, then the C#. I am not including the App file, since that class is empty. the name of this app (and its namespace is Tester).
Thanks, TJ
<Window x:Class="Tester.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:Tester"
xmlns:grid="http://infragistics.com/DataPresenter"
xmlns:igEditors="http://infragistics.com/Editors"
Loaded="Window_Loaded"
Title="Window1" MinHeight="300" MinWidth="300">
<Window.Resources>
<src:CRWithCTName x:Key="CRWithCTName"/>
<src:ControlCacheTemp x:Key="ControlCacheTemp"/>
x:Key="cboControlNameEditor">
<Setter Property="EditTemplate">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igEditors:XamTextEditor}">
<StackPanel>
<ComboBox x:Name="cboComboboxEditor" BorderThickness="0" Background="Transparent" VerticalContentAlignment="Top"
Foreground="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(TextElement.Foreground)}"
IsEditable="True" Loaded="cboComboboxEditor_Loaded" SelectionChanged="cboComboboxEditor_SelectionChanged"
SelectedValuePath="ControlID" DisplayMemberPath="ControlName" ItemsSource="{Binding Source={StaticResource ControlCacheTemp}}"
SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Text, Mode=TwoWay}"
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Text, Mode=TwoWay}">
<ComboBox.Resources>
<Style TargetType="Popup">
<Setter Property="TextElement.Foreground"
Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
</Style>
</ComboBox.Resources>
</ComboBox>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Window.Resources>
<Grid>
<grid:XamDataGrid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="20,30,20,2" Name="dgControls" MinWidth="400" MinHeight="100"
DataSource="{Binding Source={StaticResource CRWithCTName}}" IsEnabled="True" AutoFit="True"
InitializeTemplateAddRecord="dgControls_InitializeTemplateAddRecord" IsNestedDataDisplayEnabled="False">
<grid:XamDataGrid.FieldLayoutSettings>
<grid:FieldLayoutSettings AllowAddNew="True" AllowDelete="True" AddNewRecordLocation="OnTopFixed" HighlightAlternateRecords="True"
DataRecordSizingMode="SizedToContentAndIndividuallySizable" AutoGenerateFields="False" >
</grid:FieldLayoutSettings>
</grid:XamDataGrid.FieldLayoutSettings>
<grid:XamDataGrid.FieldLayouts>
<grid:FieldLayout>
<grid:FieldLayout.Fields>
<grid:Field Name="ControlID" Visibility="Collapsed">
<grid:Field.Settings>
<grid:FieldSettings AllowEdit="True" AllowGroupBy="False"/>
</grid:Field.Settings>
</grid:Field>
<grid:Field Name="ControlName" Visibility="Visible" Label="Control Name" Column="1">
<grid:Field Name="ControlTypeID" Visibility="Collapsed">
<grid:Field Name="ControlTypeName" Visibility="Visible" Label="Control Type Name" Column="2">
</grid:FieldLayout.Fields>
</grid:FieldLayout>
</grid:XamDataGrid.FieldLayouts>
</grid:XamDataGrid>
</Window>
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Infragistics.Windows.DataPresenter.Events;
using Infragistics.Windows.DataPresenter;
using Infragistics.Windows.Editors;
using Infragistics.Windows.Commands;
//using ControlDataCache;
using System.ComponentModel;
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
DataRecord _addRecord = null;
InitializeComponent();
}
_addRecord.Cells["ControlName"].EditorStyle = null;
_addRecord = e.TemplateAddRecord;
if (item == null)
_addRecord.Cells["ControlName"].Value = item.ControlName;
_addRecord.Cells["ControlTypeName"].Value = item.ControlTypeName;
public class ControlRecordWithControlTypeName
ControlID = controlID;
ControlName = controlName;
ControlTypeID = controlTypeID;
ControlTypeName = controlTypeName;
public short ControlTypeID { get; set; }
AllowEdit = AllowNew = AllowRemove = RaiseListChangedEvents = true;
public class ControlCacheTemp : BindingList<ControlRecordWithControlTypeName>, IDisposable
Dispose(true);
Both.
Thanks. TJ