How to know in codebehind when XmlDataProvider has filled target controll with data

43 views Asked by At

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";
}
1

There are 1 answers

0
AnjumSKhan On
  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.