【发布时间】:2020-01-30 17:47:55
【问题描述】:
我有一个扩展器(下面的代码),我在其中添加了一个 StackPanel 和几个按钮。当我测试代码时,它们都会显示出来,但是我不知道如何为按钮编写点击事件。关于如何实现此功能的任何想法?
<Expander x:Name="DBListing" ExpandDirection="Down" Header="DB List" Background="#FF644117" Foreground="LightGoldenrodYellow">
<StackPanel Orientation="Vertical">
<Button x:Name="EdiBtn" Content="EDI DB" Margin="0,0,0,0" Width="100" Height="30" Background="LightGoldenrodYellow" Foreground="#FF644117"/>
<Button x:Name="IssuesBtn" Content="Issues DB" Margin="0,10,0,0" Width="100" Height="30" Background="LightGoldenrodYellow" Foreground="#FF644117"/>
<Button x:Name="InterimBtn" Content="Interim DB" Margin="0,10,0,0" Width="100" Height="30" Background="LightGoldenrodYellow" Foreground="#FF644117"/>
</StackPanel>
</Expander>
我尝试在 xaml.cs 文件中分别为每个按钮设置一个单击事件,并且我还尝试为 Expander 设置一个 switch 语句。到目前为止没有运气。
【问题讨论】:
-
您需要更具体地了解 exact 问题的未来。见How to ask a good question。