Sign In|Join
Home/Silverlight.NET Forums/General Silverlight Programming/Silverlight Controls and Silverlight Toolkit/How to bind click event for button to the Inside DataGrid's Button
Last post Nov 15, 2008 09:36 AM by preishuber
Member
16 Points
61 Posts
Nov 15, 2008 04:31 AM | LINK
I have tried this
<data:DataGrid x:Name="dgSample" AutoGenerateColumns="False"> <data:DataGrid.Columns> <data:DataGridTemplateColumn Width="100"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button Content="{Binding Content}" Click="{Binding Click}" ></Button> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate> </data:DataGridTemplateColumn> </data:DataGrid.Columns> </data:DataGrid>
Button btnTemp = new Button(); btnTemp.Content = "Hello"; btnTemp.Click += new RoutedEventHandler(btnTemp_Click); List<Button> lstBtn = new List<Button>(); lstBtn.Add(btnTemp); dgSample.ItemsSource = lstBtn;
But it gives me error
Error 1 The "ValidateXaml" task failed unexpectedly.
System.InvalidOperationException: Stack empty.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.Stack`1.Pop()
at MS.MarkupCompiler.ValidationPass.ValidateXaml(String fileName, Assembly[] assemblies, Assembly callingAssembly, TaskLoggingHelper log, Boolean shouldThrow)
at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute()
at Microsoft.Silverlight.Build.Tasks.ValidateXaml.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
Is there another way to bind the Button with DataGrid ?
Plz Help.
Contributor
3572 Points
658 Posts
Nov 15, 2008 08:52 AM | LINK
why do you try to bind the click event? (guess not possible)
and not <Button Content="{Binding Content}" Click="Button_click" ></Button>
Nov 15, 2008 09:36 AM | LINK
i have added a small article to my blog which describes the details
http://weblogs.asp.net/hpreishuber/
shan_aspdotnet
Member
16 Points
61 Posts
How to bind click event for button to the Inside DataGrid's Button
Nov 15, 2008 04:31 AM | LINK
I have tried this
<data:DataGrid x:Name="dgSample" AutoGenerateColumns="False">
<data:DataGrid.Columns>
<data:DataGridTemplateColumn Width="100">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="{Binding Content}" Click="{Binding Click}" ></Button>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>
</data:DataGrid.Columns>
</data:DataGrid>
Button btnTemp = new Button();
btnTemp.Content = "Hello";
btnTemp.Click += new RoutedEventHandler(btnTemp_Click);
List<Button> lstBtn = new List<Button>();
lstBtn.Add(btnTemp);
dgSample.ItemsSource = lstBtn;
But it gives me error
Error 1 The "ValidateXaml" task failed unexpectedly.
System.InvalidOperationException: Stack empty.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.Stack`1.Pop()
at MS.MarkupCompiler.ValidationPass.ValidateXaml(String fileName, Assembly[] assemblies, Assembly callingAssembly, TaskLoggingHelper log, Boolean shouldThrow)
at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute()
at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute()
at Microsoft.Silverlight.Build.Tasks.ValidateXaml.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)
Is there another way to bind the Button with DataGrid ?
Plz Help.
Asp.Net, Silverlight
preishuber
Contributor
3572 Points
658 Posts
Re: How to bind click event for button to the Inside DataGrid's Button
Nov 15, 2008 08:52 AM | LINK
why do you try to bind the click event? (guess not possible)
and not <Button Content="{Binding Content}" Click="Button_click" ></Button>
http://www.ppedv.de
preishuber
Contributor
3572 Points
658 Posts
Re: How to bind click event for button to the Inside DataGrid's Button
Nov 15, 2008 09:36 AM | LINK
i have added a small article to my blog which describes the details
http://weblogs.asp.net/hpreishuber/
http://www.ppedv.de