We have an application where we need to display editable properties in a grid dynamically. On our core business object, we have a collection of property name/value objects that are indexed by the property name.
We had thought the string indexer support in 10.3 would keep us from having to create custom columns in order to perform the appropriate binding. In short, we need to provide a binding path to the column in the form "Properties[KeyName].Value", but xamGrid throws an exception when this syntax is used. We have confirmed that the syntax is correct and other databinding requirements have been met by creating a custom column and specifying this path.
Due to the dynamic nature of the properties, all of the columns are added in code-behind and there is no possibility of creating corresponding properties on the core business object.
The rough classes involved are:
Public Class NameValuePair Public Property Name As String Public Property Value As StringEnd Class Public Class NameValuePairCollection Inherits System.Collections.ObjectModel.KeyedCollection(Of String, NameValuePair) Protected Overrides Function GetKeyForItem(item As NameValuePair) As String Return item.Name End FunctionEnd Class Public Class File Public Properties As NameValuePairCollectionEnd Class
Hello ,
We have looked into your issue and here i am attaching a sample that is extracted from your code that you provided . Is that what you were trying to do? I hope that helps.
Regards,
Nikola.
Thank you for the sample; it validated that I was implementing this functionality correctly. However, whenever I edit the cell, I received the following exception:
) General Information*********************************************TimeStamp: 2/16/2011 10:01:25 AMAssembly: Encompass.Silverlight.DMSAppDomainName: Silverlight AppDomain1) Exception Information*********************************************Exception Type: System.ExceptionMessage: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))StackTrace Information********************************************* at MS.Internal.XcpImports.CheckHResult(UInt32 hr) at MS.Internal.XcpImports.SetValue(IManagedPeerBase obj, DependencyProperty property, DependencyObject doh) at System.Windows.DependencyObject.SetValue(DependencyProperty property, DependencyObject doh) at Infragistics.Controls.Grids.Primitives.TextColumnContentProvider.ResolveEditorControl(Cell cell, Object editorValue, Double availableWidth, Double availableHeight, Binding editorBinding) at Infragistics.Controls.Grids.CellControl.AddEditorToControl() at Infragistics.Controls.Grids.Cell.EnterEditMode(Boolean cellIsEditing) at Infragistics.Controls.Grids.XamGrid.EnterCellToEditModeInternalRow(Cell cell, Boolean currentEditCell) at Infragistics.Controls.Grids.XamGrid.EnterEditModeInternal(Row row, Cell cell) at Infragistics.Controls.Grids.XamGrid.EnterEditMode(Row row, CellBase cell) at Infragistics.Controls.Grids.XamGrid.SetActiveCell(CellBase cell, CellAlignment alignment, InvokeAction action, Boolean allowSelection, Boolean setFocus, Boolean scrollIntoView) at Infragistics.Controls.Grids.XamGrid.SetActiveCell(CellBase cell, CellAlignment alignment, InvokeAction action, Boolean allowSelection, Boolean scrollIntoView) at Infragistics.Controls.Grids.XamGrid.SetActiveCell(CellBase cell, CellAlignment alignment, InvokeAction action, Boolean allowSelection) at Infragistics.Controls.Grids.Cell.OnCellMouseDown(MouseEventArgs e) at Infragistics.Controls.Grids.XamGrid.XamWebGrid_MouseLeftButtonDown(Object sender, MouseButtonEventArgs e) at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
I did not receive this exception when running your sample. I finally tracked the issue down to the setting of the EditorStyle when I create the column in code-behind which I had been doing to remove the padding and margin on a custom combobox column (which I have since resolved by overriding the RemovePaddingDuringEditing property on the contentprovider).
So, my particular issue is fixed, but anyone attempting to set the EditorStyle in this situation will run into this exception.
What type of control are you targeting with your EditorStyle?
We we applying it to all column types, but the exception that I provided was for a TextColumn.
What i mean is what control are you targeting for your style?
<Style TargetType=" ? "/>
For a TextColumn you need to be targeting a TextBox for the EditorStyle
-SteveZ
Sorry, I meant to include that, but got distracted. Here is the style:
<Style x:Key="Standard" TargetType="ig:CellControl"> <Setter Property="Padding" Value="0"/> </Style>
Sorry about that dumb mistake; I'm quite new to styling in silverlight, so don't have my head completely wrapped around it yet.
So the TargetType needs to be a TextBox for a TextColumn.
It's not a property for styling cells. It's a property for styling the editor within.