This question is locked. New answers and comments are not allowed.
Hello,
I'm having some problems trying to add the following DataColumn to the grid programmatically:
<telerik:GridViewDataColumn>
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<Image Source="Images/vcf_small.jpg" Height="16"
MouseLeftButtonUp="VcardImage_MouseLeftButtonUp"
Tag="{Binding ID}" ToolTipService.ToolTip="Click to open the vCard."
/>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
I've tried many ways to convert the layout above into code, but then the app blows up. Here is one of the versions of the code behind:
...
GridViewDataColumn gc;
DataTemplate dt;
dt = new DataTemplate();
dt = (DataTemplate)XamlReader.Load(
@"<DataTemplate
xmlns=""http://schemas.microsoft.com/client/2007"">
<Image Source=""Images/vcf_small.jpg"" Height=""16"" ToolTipService.ToolTip=""Click to open the vCard."" Tag=""{Binding ID}"" MouseLeftButtonUp=""VcardImage_MouseLeftButtonUp""/>
</DataTemplate>"
);
gc = new GridViewDataColumn();
gc.CellTemplate = dt;
rgvMainGrid.Columns.Add(gc); //Adding the column to the grid
If I use the code above, the app blows up because of the highlighted MouseLeftButtonUp="...". If I remove it, the column adds up just fine. If i use a Button instead of the Image, I get the same problem. How can I add the column like this to the grid?
Thank you!
-VK.
I'm having some problems trying to add the following DataColumn to the grid programmatically:
<telerik:GridViewDataColumn>
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<Image Source="Images/vcf_small.jpg" Height="16"
MouseLeftButtonUp="VcardImage_MouseLeftButtonUp"
Tag="{Binding ID}" ToolTipService.ToolTip="Click to open the vCard."
/>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
I've tried many ways to convert the layout above into code, but then the app blows up. Here is one of the versions of the code behind:
...
GridViewDataColumn gc;
DataTemplate dt;
dt = new DataTemplate();
dt = (DataTemplate)XamlReader.Load(
@"<DataTemplate
xmlns=""http://schemas.microsoft.com/client/2007"">
<Image Source=""Images/vcf_small.jpg"" Height=""16"" ToolTipService.ToolTip=""Click to open the vCard."" Tag=""{Binding ID}"" MouseLeftButtonUp=""VcardImage_MouseLeftButtonUp""/>
</DataTemplate>"
);
gc = new GridViewDataColumn();
gc.CellTemplate = dt;
rgvMainGrid.Columns.Add(gc); //Adding the column to the grid
If I use the code above, the app blows up because of the highlighted MouseLeftButtonUp="...". If I remove it, the column adds up just fine. If i use a Button instead of the Image, I get the same problem. How can I add the column like this to the grid?
Thank you!
-VK.