假设一个StackPanel控件就是你的主窗口,一个Button控件就是你的图标。
WPF的语句:
<Button Content="展开" Name="Button1" />
<StackPanel Visibility="Collapsed" Name="StackPanel1"/>
如果用C#编程
private void button1_Click(object sender, RoutedEventArgs e)
{
string value
value = button1.Content.ToString()
if (value == "展开")
{
stackPanel1.Visibility = System.Windows.Visibility.Visible
button1.Content = "收起"
}
else if (value == "收起")
{
stackPanel1.Visibility = System.Windows.Visibility.Collapsed
button1.Content = "展开"
}
}
如果用VB.NET编程
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
If Button1.Content = "展开" Then
StackPanel1.Visibility = Windows.Visibility.Visible
Button1.Content = "收起"
ElseIf Button1.Content = "收起" Then
StackPanel1.Visibility = Windows.Visibility.Collapsed
Button1.Content = "展开"
End If
End Sub
希望能够帮到你!!!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)