I've got an expander (code below), to which I've added a StackPanel and a few buttons. They all show when I test the code, however I can't figure out how to code a click event for the buttons. Any ideas on how to get this functioning?
<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>
I've tried setting up a click event for each button separately in the xaml.cs file, and I've also tried to set up a switch statement for the Expander. No luck thus far.
Subscribe to the Click
event in the Xaml by these steps.
Click=
. Once done Visual Studio intellesense will offer a name as a popup. Click on that to accept. Notice how the attribute is now filled out like Click="ButtonOperation"
. In the future put you can put a name more fitting for the operation."{name}"
text just created. MessageBox.Show("Jabberwocky");
in the method, compile and run