Hi,I am trying to add an event handler to a button that is displayed dynamically in the rows of a result set from a query task. In the results, for one of the fields, I want to display a button and add an event handler for it when the user clicks the button.The following code without a click event handler works, but does nothing since there is no click handler:
string attributeName = "GEOSCANREC";
DataTemplate cellTemplate =
(DataTemplate)System.Windows.Markup.XamlReader.Load(@"<DataTemplate xmlns=""http://schemas.microsoft.com/client/2007"">
<Button Content=""{Binding Attributes[" + attributeName + @"], StringFormat='\{0\}'}""
ToolTipService.ToolTip=""{StaticResource strDisplayGeoscanRecord}"" >
</Button> </DataTemplate>");
QueryDetailsDataGrid.Columns.Add(new DataGridTemplateColumn()
{
Width = new DataGridLength(115),
Header = LanguageResources.strGeoscanHeader.ToString(),
CellTemplate = cellTemplate
});
The above creates a column as seen in the image Results.png attached.If I take the same code and add a handler:
string attributeName = "GEOSCANREC";
DataTemplate cellTemplate =
(DataTemplate)System.Windows.Markup.XamlReader.Load(@"<DataTemplate xmlns=""http://schemas.microsoft.com/client/2007"">
<Button Content=""{Binding Attributes[" + attributeName + @"], StringFormat='\{0\}'}""
Click=""btnGeoscan_Click""
ToolTipService.ToolTip=""{StaticResource strDisplayGeoscanRecord}"" >
</Button> </DataTemplate>");
QueryDetailsDataGrid.Columns.Add(new DataGridTemplateColumn()
{
Width = new DataGridLength(115),
Header = LanguageResources.strGeoscanHeader.ToString(),
CellTemplate = cellTemplate
});
I get the error you see in the attached image Error.png. This message gives you no help on what is wrong with the code. Why can't I add the handler???Paul