Datagridcontrol does not Display Data when Data is loaded with delay
Hello,
I'm new to the Syncfusion Framework (and also to the WPF at whole). I want to use the DataTreeControl to display a hierarchy of data which will be loaded and updated in a reoccuring interval. But for some reason it doesn't display the data.
Here's a snipped from my MainWindow.xaml
<syncfusion:TabItemExt Name="_tabItemTipps" Header="Tipps">
<syncfusion:GridTreeControl Name="_treeGrid"
BorderBrush="LightGray"
BorderThickness="0,0.5,0,0"
EnableHotRowMarker="False"
EnableNodeSelection="True"
ExpandStateAtStartUp="AllNodesExpanded"
ReadOnly="True"
SupportNodeImages="True"
VisualStyle="Metro"
ItemsSource="SoccerMarkets"
>
<!-- Code for GridTreeControl Columns -->
<syncfusion:GridTreeControl.Columns>
<syncfusion:GridTreeColumn HeaderText="Nation" MappingName="{Binding RoughCat}"></syncfusion:GridTreeColumn>
</syncfusion:GridTreeControl.Columns>
</syncfusion:GridTreeControl>
</syncfusion:TabItemExt>
This the snippet from MainWindow.xaml.cs where the DataContext is set:
public MainWindow()
{
DataContext = this;
InitializeComponent();
SkinStorage.SetVisualStyle(_tabControl, "Metro");
_settingsVM = new AppSettingsVM();
_txtBetdaqUser.DataContext = _settingsVM;
_chkSystemActive.DataContext = _settingsVM;
_chkInSimulationMode.DataContext = _settingsVM;
_mechanic = new TippMechanic(_settingsVM);
_soccerMarketsVM = new SoccerMarketVM();
Task[] tasks = new Task[1];
tasks[0] = Task.Factory.StartNew(async () => await _mechanic.Init());// _mechanic.Init();
Task.WaitAll(tasks);
_soccerMarketsVM.SoccerMarkets = _mechanic.SoccerMarketManager.SoccerMarkets;
_treeGrid.DataContext = _soccerMarketsVM.SoccerMarkets;
}
My ViewModel (_soccerMarketsVM) is defined this way:
class SoccerMarketVM : ObservableObject
{
private ObservableCollection<SoccerMarket> _soccerMarkets;
public ObservableCollection<SoccerMarket> SoccerMarkets
{
get { return _soccerMarkets; }
set
{
if(_soccerMarkets != null)
_soccerMarkets.CollectionChanged -= _soccerMarkets_CollectionChanged;
_soccerMarkets = value;
_soccerMarkets.CollectionChanged += _soccerMarkets_CollectionChanged;
}
}
public SoccerMarketVM()
{
//_soccerMarkets = new ObservableCollection<SoccerMarket>();
//_soccerMarkets.CollectionChanged += _soccerMarkets_CollectionChanged;
}
void _soccerMarkets_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
Console.WriteLine(e.Action.ToString());
}
}
The Events for CollectionChanged are fired and I get the Console.Writeline output.
Does anyone see's something wrong here?
I'm new to the Syncfusion Framework (and also to the WPF at whole). I want to use the DataTreeControl to display a hierarchy of data which will be loaded and updated in a reoccuring interval. But for some reason it doesn't display the data.
Here's a snipped from my MainWindow.xaml
<syncfusion:TabItemExt Name="_tabItemTipps" Header="Tipps">
<syncfusion:GridTreeControl Name="_treeGrid"
BorderBrush="LightGray"
BorderThickness="0,0.5,0,0"
EnableHotRowMarker="False"
EnableNodeSelection="True"
ExpandStateAtStartUp="AllNodesExpanded"
ReadOnly="True"
SupportNodeImages="True"
VisualStyle="Metro"
ItemsSource="SoccerMarkets"
>
<!-- Code for GridTreeControl Columns -->
<syncfusion:GridTreeControl.Columns>
<syncfusion:GridTreeColumn HeaderText="Nation" MappingName="{Binding RoughCat}"></syncfusion:GridTreeColumn>
</syncfusion:GridTreeControl.Columns>
</syncfusion:GridTreeControl>
</syncfusion:TabItemExt>
This the snippet from MainWindow.xaml.cs where the DataContext is set:
public MainWindow()
{
DataContext = this;
InitializeComponent();
SkinStorage.SetVisualStyle(_tabControl, "Metro");
_settingsVM = new AppSettingsVM();
_txtBetdaqUser.DataContext = _settingsVM;
_chkSystemActive.DataContext = _settingsVM;
_chkInSimulationMode.DataContext = _settingsVM;
_mechanic = new TippMechanic(_settingsVM);
_soccerMarketsVM = new SoccerMarketVM();
Task[] tasks = new Task[1];
tasks[0] = Task.Factory.StartNew(async () => await _mechanic.Init());// _mechanic.Init();
Task.WaitAll(tasks);
_soccerMarketsVM.SoccerMarkets = _mechanic.SoccerMarketManager.SoccerMarkets;
_treeGrid.DataContext = _soccerMarketsVM.SoccerMarkets;
}
My ViewModel (_soccerMarketsVM) is defined this way:
class SoccerMarketVM : ObservableObject
{
private ObservableCollection<SoccerMarket> _soccerMarkets;
public ObservableCollection<SoccerMarket> SoccerMarkets
{
get { return _soccerMarkets; }
set
{
if(_soccerMarkets != null)
_soccerMarkets.CollectionChanged -= _soccerMarkets_CollectionChanged;
_soccerMarkets = value;
_soccerMarkets.CollectionChanged += _soccerMarkets_CollectionChanged;
}
}
public SoccerMarketVM()
{
//_soccerMarkets = new ObservableCollection<SoccerMarket>();
//_soccerMarkets.CollectionChanged += _soccerMarkets_CollectionChanged;
}
void _soccerMarkets_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
Console.WriteLine(e.Action.ToString());
}
}
The Events for CollectionChanged are fired and I get the Console.Writeline output.
Does anyone see's something wrong here?
SIGN IN To post a reply.
6 Replies
JG
Jai Ganesh S
Syncfusion Team
January 14, 2015 11:22 AM UTC
Hi SxTrader,
Thank you for using Syncfusion products.
We have analyzed your query. We have prepared a sample with Time delay to load the items and it can be downloaded from below location,
Sample Link:
Please let us know if you need further assistance.
Thank you,
Jai Ganesh S
SX
SXTrader
January 14, 2015 01:57 PM UTC
Hello Jay Ganesh,
thank you for your support. Unfortunate your sample programm does not solve my problem.
The GUI of the sample is loaded when the time delayed data has finished loading. Actually if the data loading is pushed truely into background I face the same problem: The gui is displayed with an empty gridtreecontrol and the data isn't updated when the creation of the Model data has been finished by the background worker.
I've modified your sample and attached it this thread, so that you can see the issue.
Thanks
Markus
Attachment: SelfRelational_Data_Binding_Demo_32e77799.zip
thank you for your support. Unfortunate your sample programm does not solve my problem.
The GUI of the sample is loaded when the time delayed data has finished loading. Actually if the data loading is pushed truely into background I face the same problem: The gui is displayed with an empty gridtreecontrol and the data isn't updated when the creation of the Model data has been finished by the background worker.
I've modified your sample and attached it this thread, so that you can see the issue.
Thanks
Markus
Attachment: SelfRelational_Data_Binding_Demo_32e77799.zip
SX
SXTrader
January 14, 2015 08:50 PM UTC
Hi,
I've just figured how it works with asynchrones loading and update. I will update the sample application and post it here. So others who have the same issue can have a look.
I've just figured how it works with asynchrones loading and update. I will update the sample application and post it here. So others who have the same issue can have a look.
SC
Saranya CJ
Syncfusion Team
January 23, 2015 04:28 AM UTC
Hi Markus,
Thank you for your update.
We will wait until you send us the sample application. Please let us know if you require any other assistance on this.
Regards,
Saranya
SX
SXTrader
February 2, 2015 09:38 AM UTC
Hi,
sorry for the delay. I had to do some things in my job first. You can find a working example attached to this post.
The problem seems to be that if the filling or updating of the ObservableCollection is done in background the presentation framework seems not to react on the events.
I've created a second Observable Collection. When the first one is filled or updated it fires an event which is caught by the ViewModel which compares the first Observable Collection with the second one and if neccessary adjust the second one.
It is not the best solution but a working one. A second step which I haven't done in the example project yet is to implement a NotificationObject Interface.
You can easily compare the two behaviours when you change the Binding in the XAML form PersonDetails2 back to PersonDetail or vice versa.
Attachment: SelfRelational_Data_Binding_Demo_357cc2cf.zip
sorry for the delay. I had to do some things in my job first. You can find a working example attached to this post.
The problem seems to be that if the filling or updating of the ObservableCollection is done in background the presentation framework seems not to react on the events.
I've created a second Observable Collection. When the first one is filled or updated it fires an event which is caught by the ViewModel which compares the first Observable Collection with the second one and if neccessary adjust the second one.
It is not the best solution but a working one. A second step which I haven't done in the example project yet is to implement a NotificationObject Interface.
You can easily compare the two behaviours when you change the Binding in the XAML form PersonDetails2 back to PersonDetail or vice versa.
Attachment: SelfRelational_Data_Binding_Demo_357cc2cf.zip
JG
Jai Ganesh S
Syncfusion Team
February 6, 2015 05:28 AM UTC
Hi Markus,
Thank you for your update.
Please let us know if you require any other assistance.
Regards,
Jai Ganesh S
SIGN IN To post a reply.
- 6 Replies
- 3 Participants
-
SX SXTrader
- Jan 11, 2015 06:14 PM UTC
- Feb 6, 2015 05:28 AM UTC