[英]Button won't work in DataGrid
When I build the project and the window is created, for some reason I can't get the button to depress... and it won't recognize the code behind click event neither... any ideas? 当我构建项目并创建窗口时,由于某种原因,我无法按下该按钮...并且它也无法识别click事件背后的代码...任何想法?
<DataGrid.Columns>
<DataGridTemplateColumn Header="Add / Edit">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Name="addeditBtn" Click="Add_Edit_Click">A/E</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Account Name" Binding="{Binding Path=Element[Account_Name].Value}" />
<DataGridTextColumn Header="Income" Binding="{Binding Path=Element[Income].Value}" />
</DataGrid.Columns>
UPDATE: I figured it out. 更新:我想通了。 Seems I had a got_focus event that was taking precedence over this event...
似乎我有一个got_focus事件优先于此事件...
You will need to create an Event Handler for your Button addeditBtn. 您将需要为按钮additBtn创建一个事件处理程序。 So in your Code Behind page, create the C# code that will handle the click event of the button.
因此,在您的代码隐藏页面中,创建将处理按钮的click事件的C#代码。 Have you created this code?
您创建了此代码吗? If so, please post it so that we can get a look at the code.
如果是这样,请张贴它,以便我们看一下代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.