wpf单击任务栏图标显示主窗口,再单击则主窗口消失,怎么实现
就像一些桌面图标管理程序那样(腾讯的小Q书桌),一直处于运行状态.并且锁定到任务栏,单击一下面板展开,再单击一下那个图标,面板消失,怎么实现的...
就像一些桌面图标管理程序那样(腾讯的小Q书桌),一直处于运行状态.并且锁定到任务栏,单击一下面板展开,再单击一下那个图标,面板消失,怎么实现的
展开
1个回答
展开全部
设置该面板的visibility属性就可以了
假设一个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
希望能够帮到你!!!
假设一个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
希望能够帮到你!!!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询