Hello, if I put the XamGrid into TilePane the ItemSource give me an error:
Riferimento a un oggetto non impostato su un'istanza di oggetto.
If put then XamGrid outer of TilePane the ItemSource is Ok
This is the Code:
<ig:XamTileView ColumnsInPage="2" RowsInPage="2" Name="tlOre"><ig:TilePane Header="Fascia oraria" Name="tpOre" ><ig:XamGrid Name="dgOre" AutoGenerateColumns="False" VerticalAlignment="Stretch"><ig:XamGrid.Columns><ig:TextColumn HeaderText="Ora" Key="Descrizione"/><ig:TextColumn HeaderText="Venduto" Key="Valore"/></ig:XamGrid.Columns></ig:XamGrid></ig:XamTileView>
VB
Private Sub mService_GetFasciaOrariaCompleted(ByVal sender As Object, ByVal e As ServiceReference1.GetFasciaOrariaCompletedEventArgs) Handles mService.GetFasciaOrariaCompleted
dgOre.ItemSource = e.Results
End sub
Thank you
Alessandro
(italy)
Hello Alessandro,
To access the XamGrid you can use the FindName method, passing in the name you assigned to the XamGrid:
XamGrid myGrid = tpOre.FindName("dgOre") as XamGrid;
The reason for this is that the namescope of the XamGrid gets modified when you place it within the TilePane.
For more information about the FindName method, please see the following MSDN article:
<http://msdn.microsoft.com/en-us/library/system.windows.frameworkelement.findname(VS.95).aspx>
For more information about namescopes in Silverlight, please see the following MSDN article:
<http://msdn.microsoft.com/en-us/library/cc189026(VS.95).aspx>
Please let me know if you have any further questions or concerns about this matter.
Hi,
I read your reply. I used the same code.
In XamGrid i am trying to bind the itemsource but its not binding.
Here i am mention code
-----------------------------------------------------------------------
public Test() { InitializeComponent(); XamGrid myGrid = tlOre.Items[0].FindName("dgOre") as XamGrid; //XamGrid myGrid = tpOre.FindName("dgOre") as XamGrid; LoadXMLData();
} private void LoadXMLData() { XDocument doc = XDocument.Load("Xml/Products.xml");
var data = (from d in doc.Descendants("Products") select new Product { SKU = d.Element("ProductID").Value, Name = d.Element("ProductName").Value, Category = d.Element("Category").Value, Supplier = d.Element("Supplier").Value, QuantityPerUnit = d.Element("QuantityPerUnit").Value }).ToList<Product>();
myGrid = new XamGrid(); myGrid.ItemsSource = data;
}
I am not able get the record.