I have created wpf xamdatagrid with datatable using the datasource property. Now I want to add 1 hyperlink column in the middle of the DataGrid and 1 sparkline chart in the 1st column.
Can you please help me how to do it from the code behind using c#?
If I just use the following code:
for (int i = 0; i < dtResults.Rows.Count - 1; i++)
{
TextBlock tblk = new TextBlock();
Hyperlink hlink = new Hyperlink(new Run("click"));
hlink.TargetName =
"_blank";
hlink.NavigateUri =
new Uri(http://testpage1.aspx?ID= + dtResults.Rows[i][1].ToString());
tblk.Inlines.Clear();
tblk.Inlines.Add(hlink);
xamDataGrid1.DataItems.Add(tblk);
}
The above code adds a hyperlink column in the first column, but how to add the rest columns from the DataTable?
Thanks,
Ram
Hello Ram,
Based on the approach that you are taking, you would need to create a column in your DataTable for Sparkline objects, and then add each row that contains the Sparkline, Hyperlink, etc., in the xamDataGrid's DataItem collection.
I am attaching a sample that demonstrates it. Please take a look and let me know if you have any questions.
Sam