Reputation: 9
I am working with DevExpress GridControl using MVVM this is my *.xaml
<dxg:GridControl x:Name="grid" AutoGenerateColumns="AddNew" ShowBorder="True" SelectionMode="Row" DetectNestedPropertyChanges="True" MaxHeight="{x:Static SystemParameters.PrimaryScreenHeight}"
ItemsSource="{Binding Items, Mode=TwoWay}" SelectedItems="{Binding SelectedItems}" CurrentItem="{Binding CurrentItem}" ColumnsSource="{Binding Columns, Mode=TwoWay}" ColumnGeneratorTemplate="{StaticResource DefaultColumnTemplate}"
AllowColumnMRUFilterList="False" AllowLiveDataShaping="True"
>
My Items and columns collection in the VM
public RangeObservableCollection<object> Items
{
get => GetValue<RangeObservableCollection<object>>();
set => SetValue(value);
}
public ObservableCollection<Column> Columns
{
get => GetValue<ObservableCollection<Column>>();
set => SetValue(value);
}
I have a method call that creates a JSON string and Deserializes it
public void CreateCollection()
{
for (int i = 0; i < 100; i++)
{
string json = @"
{
""TagName"": """ + $"TagName{i}" + @""",
""User"": """ + $"User{i}" + @""",
""TagDateTime"": """ + DateTime.UtcNow.ToString("MM-dd-yyyy HH:mm:ss.fff K") + @""",
""" + $"Tag{i}" + @""": """ + $"Value{i}" + @"""
}";
dynamic tag = JsonConvert.DeserializeObject(json)!;
var d = JsonConvert.DeserializeObject<Dictionary<string, dynamic>>(json)!;
foreach (var key in d.Keys)
{
var column = new Column(key);
if(!Columns.Contains(column))
Columns.Add(column);
}
Items.Add(tag);
}
}
As shown in the image the data that comes back only displays the first instance of the dynamic data. If I change the order I can verify that. I am trying to display all the data in each column for each row.
Upvotes: -1
Views: 21