I am trying to create a custom CellValue presenter, and was able to do so following some of the examples I found. My problem is I can not get the cell to be editable when I click on it. In using debugger, and looking at cellvalues, everything appears to be set for AllowEdit. Any suggestions? Here is the code I am using:
<Window.Resources> <ResourceDictionary>
<local:CurrentStyleConverter x:Key="CurrentStyleConverter"/>
</ResourceDictionary></Window.Resources>
<inf:XamDataGrid Name="grid"> <inf:XamDataGrid.FieldSettings> <inf:FieldSettings AllowEdit="True" /> </inf:XamDataGrid.FieldSettings>
<inf:XamDataGrid.FieldLayoutSettings> <inf:FieldLayoutSettings x:Uid="inf:FieldLayoutSettings_1" HighlightAlternateRecords="True" AddNewRecordLocation="OnBottom" AllowAddNew="True" AllowDelete="True" /> </inf:XamDataGrid.FieldLayoutSettings> <inf:XamDataGrid.FieldLayouts>
<inf:FieldLayout> <inf:FieldLayout.Fields>... <inf:Field Name="ElapsedTime" Label="Elapsed Time" > <inf:Field.Settings> <inf:FieldSettings AllowEdit="True" CellValuePresenterStyle="{StaticResource myPeriodicUpdateCell}" EditAsType="{x:Type sys:String}" EditorType="{x:Type infe:XamTextEditor}" > <inf:FieldSettings.EditorStyle> <Style TargetType="{x:Type infe:XamTextEditor}" /> </inf:FieldSettings.EditorStyle> </inf:FieldSettings> </inf:Field.Settings> </inf:Field> </inf:FieldLayout.Fields> </inf:FieldLayout> </inf:XamDataGrid.FieldLayouts></inf:XamDataGrid>
class CurrentStyleConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is TimeSpan) { TimeSpan ts = (TimeSpan)value; return string.Format("{0:D2}:{1:D2}:{2:D2}", ts.Hours, ts.Minutes, ts.Seconds); } return value; }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { // tried putting anything here to see if it helped... didn't work return TimeSpan.FromSeconds(20); }}
Hello mpgoodma,I have been looking into your issue and the xaml snippet you have provided and suppose you have created you’re your own ContentPresenter class, to replace the one used in the CellValuePresenter class. By creating your own template you have actually replace the existing one that provides most of the CellValuePresneter’s functionality and this is why such behavior is expected. If you want to add or alter anything in the CellValuepResenter you create a style using the original template which we provide along with our product just for such purposes. You can find it in the DefaultStyles folder which is installed by default here: C:\Program Files (x86)\Infragistics\NetAdvantage 2010.3\WPF\DefaultStyles and in it you can use: \DataPresenter\DataPresenterGeneric_Express.xaml file to the copy you need. If you still need to use your own ContentPresenter I can suggest you set the same as the default styles’ ContentPresenter since it is used to map the XamEditors for each column which actually provide the editing functionality.Please let me know if you require any further assistance on the matter.