在线请教,winform移动控件 winform里有没有类似于WPF的移动控件,当鼠标靠近时渐渐移动出来,鼠标离开时渐渐隐藏。有吗?没有的话用,winform该如何达到该种效果呢?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 有,建议你去看哈Dockpanel的框架,那个绝对能实现你要的效果。他实现的界面类似VS的开发工具的界面 这个试过,但效果欠缺,尤其是控件move时会出现轻微的闪烁 WPF里的控件的确是没问题的,但偶没用过WPF啊…… 没用过不要紧啊,啥事都有第一次,自己尝试着用用,要相信自己三楼的Dockpanel也不错!值得学学。 LZ说的“移动控件”是个什么控件?英文名叫啥?还有你说“当鼠标靠近时渐渐移动出来”是鼠标移动到控件上以后才慢慢显示出来吧?如果是那样的话,可以通过mouseEnter和MouseLeave事件来控制的 “移动控件”貌似没有具体的名字,鼠标靠近的不是控件上,一开始控件是隐藏的。如果仅仅是要这种效果,其实用mouseMove,timer,设置标志位,就能达到,但winform的控件移动时会出现闪烁的效果,不大好。不知道有没有好方法解决这个问题 直接用wpf吧毕竟以后会往wpf发展...winform就用custom control实践吧... 那能给我个WPF的例子看看吗?因为实在不太明白这个控件到底是实现了什么样的功能,我也就没法看是否能在winform里做同样的效果了 我也想用WPF,那具体应该如何实现呢 如果方便的话,你上Stellarium官网下一个Stellarium的软件,打开软件后应该就能看到我想实现的效果了…… <Button x:Name="button" Content="Button"> <Button.Style> <Style> <Style.Triggers> <Trigger Property="Button.IsMouseOver" Value="True"> <Setter Property="Button.Background" Value="Red" /> </Trigger> </Style.Triggers> </Style> </Button.Style> </Button>利用Triggers就可以触发事件DoubleAnimation,ThicknessAnimation搭配Storyboard去控制Ocapity(透明)跟Margin属性就可以做到渐出的效果void StartAnimiation() { DoubleAnimation daleft = new DoubleAnimation(); daleft.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration)); daleft.RepeatBehavior = new RepeatBehavior(1); daleft.AutoReverse = false; Thickness tkleft = leftdoor.Margin; ThicknessAnimation taleft = new ThicknessAnimation(); taleft.From = tkleft; taleft.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration)); DoubleAnimation daright = new DoubleAnimation(); daright.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration)); daright.RepeatBehavior = new RepeatBehavior(1); daright.AutoReverse = false; Thickness tkright = rightdoor.Margin; ThicknessAnimation taright = new ThicknessAnimation(); taright.From = tkright; taright.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration)); if (isOpened) { daleft.From = this.leftdoor.Width; daleft.To = this.Width / 2 - OpenWidth; tkleft.Right = this.Width - OpenWidth; taleft.To = tkleft; daright.From = this.rightdoor.Width; daright.To = this.Width / 2 - OpenWidth; tkright.Left = this.Width - OpenWidth; taright.To = tkright; } else { daleft.From = this.leftdoor.Width; daleft.To = this.Width / 2; tkleft.Right = (this.Width / 2); taleft.To = tkleft; daright.From = this.rightdoor.Width; daright.To = this.Width / 2; tkright.Left = (this.Width / 2); taright.To = tkright; } Storyboard sbleft = new Storyboard(); Storyboard.SetTargetProperty(taleft, new PropertyPath(Rectangle.MarginProperty)); sbleft.Children.Add(taleft); Storyboard.SetTargetProperty(daleft, new PropertyPath(Rectangle.WidthProperty)); sbleft.Children.Add(daleft); sbleft.Begin(leftdoor); Storyboard sbright = new Storyboard(); Storyboard.SetTargetProperty(taright, new PropertyPath(Rectangle.MarginProperty)); sbright.Children.Add(taright); Storyboard.SetTargetProperty(daright, new PropertyPath(Rectangle.WidthProperty)); sbright.Children.Add(daright); sbright.Begin(rightdoor); }我做的是一个开关门的动画效果.....控制的是Width跟Margin.... http://blog.csdn.net/cloudhsu/archive/2010/09/24/5903572.aspx可参考这篇文章 你说的是那个软件左下角那个类似于panel的控件吗?当我鼠标移动过去的时候,它就向上移动了,移动出去的时候它就向下移动了 嗯,没错,就是类似的效果。假如那个panel放在左边。鼠标移开的时候panel向左移动,直至看不到。当鼠标移到那附近时,panel开始向右移动直至完全显示 C# 小弟准备学习c#的asp.net,请问读什么书入门最好? 如何添加panel的背景色? 如何實現函數功能說明? .net的安全策略是怎么回事?譬如说:在用………… 一个异步调用的问题(Server 属性) 水晶报表加载提示 系统找不到指定路径 Visual Studio 中的 Exceptions 窗口在哪里? 努力学习C#中,期盼朋友的交流,每天至少10个小时在线!!! 我是新手,帮帮忙吧!!! 程序超慢 windows Service安装到另一台电脑出现问题
没用过不要紧啊,啥事都有第一次,自己尝试着用用,要相信自己
三楼的Dockpanel也不错!值得学学。
不知道有没有好方法解决这个问题
毕竟以后会往wpf发展...
winform就用custom control实践吧...
那能给我个WPF的例子看看吗?因为实在不太明白这个控件到底是实现了什么样的功能,我也就没法看是否能在winform里做同样的效果了
<Button.Style>
<Style>
<Style.Triggers>
<Trigger Property="Button.IsMouseOver" Value="True">
<Setter Property="Button.Background" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
利用Triggers就可以触发事件
DoubleAnimation,ThicknessAnimation搭配Storyboard去控制Ocapity(透明)跟Margin属性
就可以做到渐出的效果void StartAnimiation()
{
DoubleAnimation daleft = new DoubleAnimation();
daleft.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration));
daleft.RepeatBehavior = new RepeatBehavior(1);
daleft.AutoReverse = false;
Thickness tkleft = leftdoor.Margin;
ThicknessAnimation taleft = new ThicknessAnimation();
taleft.From = tkleft;
taleft.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration)); DoubleAnimation daright = new DoubleAnimation();
daright.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration));
daright.RepeatBehavior = new RepeatBehavior(1);
daright.AutoReverse = false;
Thickness tkright = rightdoor.Margin;
ThicknessAnimation taright = new ThicknessAnimation();
taright.From = tkright;
taright.Duration = new Duration(new TimeSpan(0, 0, 0, 0, AnimationDuration)); if (isOpened)
{
daleft.From = this.leftdoor.Width;
daleft.To = this.Width / 2 - OpenWidth;
tkleft.Right = this.Width - OpenWidth;
taleft.To = tkleft;
daright.From = this.rightdoor.Width;
daright.To = this.Width / 2 - OpenWidth;
tkright.Left = this.Width - OpenWidth;
taright.To = tkright;
}
else
{
daleft.From = this.leftdoor.Width;
daleft.To = this.Width / 2;
tkleft.Right = (this.Width / 2);
taleft.To = tkleft; daright.From = this.rightdoor.Width;
daright.To = this.Width / 2;
tkright.Left = (this.Width / 2);
taright.To = tkright;
} Storyboard sbleft = new Storyboard();
Storyboard.SetTargetProperty(taleft, new PropertyPath(Rectangle.MarginProperty));
sbleft.Children.Add(taleft);
Storyboard.SetTargetProperty(daleft, new PropertyPath(Rectangle.WidthProperty));
sbleft.Children.Add(daleft);
sbleft.Begin(leftdoor); Storyboard sbright = new Storyboard();
Storyboard.SetTargetProperty(taright, new PropertyPath(Rectangle.MarginProperty));
sbright.Children.Add(taright);
Storyboard.SetTargetProperty(daright, new PropertyPath(Rectangle.WidthProperty));
sbright.Children.Add(daright);
sbright.Begin(rightdoor);
}我做的是一个开关门的动画效果.....
控制的是Width跟Margin....
你说的是那个软件左下角那个类似于panel的控件吗?当我鼠标移动过去的时候,它就向上移动了,移动出去的时候它就向下移动了