0

The title of my question says it already. How can I check if my XmlDataProvider has filled my DataGrid in code behind. It already works, but I want to check when it is finished so I can style the cells in my DataGrid(ForeGround, Background, TextWeight) before the user is able to do/see anything:

public ExcelWindow(string filePath)
{
    InitializeComponent();
    _filePath = filePath;

    Dispatcher.beginInvoke((Action)(() =>
    {
        LoadScreenSettings();
    }));

    LoadXml();

    CellLayoutHandler = new CellLayoutHandler(DataGridXml, _FilePath);
}

private void LoadXml()
{
    XmlDataProvider dataProvider = xmlDataProvider;
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(_FilePath);
    dataProvider.Document = xmlDoc;
    dataProvider.XPath = "Data/Row";
}
Florian Schaal
  • 2,586
  • 3
  • 39
  • 59
NickGames
  • 312
  • 1
  • 18
  • 1) If you want to see exactly see when it is finished, alternatively you can use Background worker. Backgroundworker has event like "RunWorkerCompleted" – Ugur Jul 11 '16 at 11:52
  • 2) Or just create a custom data grid style regarding your data in XML. – Ugur Jul 11 '16 at 11:53
  • Ok I will look into it thanks! But there has to be an easier way to do this right? I can't imagine it is that hard to achieve this in a simpler way.. – NickGames Jul 11 '16 at 12:11

1 Answers1

0
  1. Use LoadingRow event : Dgrd.LoadingRow += DgrdParent_LoadingRow;, beauty of this event is only visible Rows fire this event, if you scroll down or increase the size of the Window, remaining relevant rows will fire this event.

  2. Use HasItems property. This property becomes True only when DataGrid is finished with its ItemsSource.

AnjumSKhan
  • 9,647
  • 1
  • 26
  • 38