Hi,
I have the following RadGridView where its ItemsSource which is bound to a collection that its item is inherited from DynamicObject.
As shown in the screenshot, how can i prevent the column name with "." being truncated in TryGetMember() method?
<
telerik:RadGridView
Grid.Row
=
"1"
Margin
=
"4"
GroupRenderMode
=
"Flat"
ShowGroupPanel
=
"False"
RowIndicatorVisibility
=
"Collapsed"
CanUserFreezeColumns
=
"False"
ItemsSource
=
"{Binding TestResultRecords, Mode=OneWay}"
AutoGenerateColumns
=
"True"
IsReadOnly
=
"True"
CanUserReorderColumns
=
"False"
CanUserInsertRows
=
"False"
CanUserDeleteRows
=
"False"
behavior:MyScrollIntoViewAsyncBehavior.IsEnabled
=
"{Binding IsScrollToView, Mode=OneWay}"
>
<
telerik:RadGridView.SortDescriptors
>
<
telerik:SortDescriptor
Member
=
"{x:Static res:UIStringTable.DutCnt}"
SortDirection
=
"Ascending"
/>
</
telerik:RadGridView.SortDescriptors
>
</
telerik:RadGridView
>
TestResultRecords = new ObservableCollection<
VolatileDynamicColRecord
>();
m_TestRecord = new VolatileDynamicColRecord();
m_TestRecord["Sweep Voltage1-@2.5mA(V)"] = 1234
m_TestRecord["Sweep Voltage1-@2.8mA(V)"] = 5678
m_TestRecord["Sweep Voltage1-Item3(V)"] = 2.74353
TestResultRecords.Add(m_TestRecord);
public class VolatileDynamicColRecord : DynamicObject, INotifyPropertyChanged
{
private readonly IDictionary<
string
, object> m_Data;
public VolatileDynamicColRecord()
{
m_Data = new Dictionary<
string
, object>();
}
public VolatileDynamicColRecord(IDictionary<
string
, object> source)
{
m_Data = source;
}
public override IEnumerable<
string
> GetDynamicMemberNames()
{
return m_Data.Keys;
}
public IEnumerable<
object
> GetDynamicMemberValues()
{
return m_Data.Values;
}
public override bool TryGetMember(GetMemberBinder binder, out object result)
{
// Note: when column name contains ".", the text after "." will be truncated.
result = this[binder.Name];
return result != null ? true : false;
}
public override bool TrySetMember(SetMemberBinder binder, object value)
{
if (this[binder.Name] == null)
{
return false;
}
this[binder.Name] = value;
return true;
}
public object this[string columnName]
{
get
{
if (m_Data.ContainsKey(columnName))
{
return m_Data[columnName];
}
return null;
}
set
{
if (!m_Data.ContainsKey(columnName))
{
m_Data.Add(columnName, value);
OnPropertyChanged(columnName);
}
else
{
if (m_Data[columnName] != value)
{
m_Data[columnName] = value;
OnPropertyChanged(columnName);
}
}
}
}
private void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion