我正在创建一个Windows应用程序(WPF)和C#。在我看来,我必须添加一些布局,比如浏览文件夹,在列表view...etc中显示文件夹中的文件
我的要求是:上面提到的面板应该是可折叠的面板,我想,我们在wpf中没有可折叠面板的选项。
我必须为此创建自定义控件吗?如果是这样的话,请建议我怎么做?
发布于 2013-11-28 12:11:30
可能会喜欢这个?
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<Border Background="Red" Height="12" VerticalAlignment="Top" MouseEnter="StackPanel_MouseEnter" MouseLeave="StackPanel_MouseLeave"></Border>
</Grid>
C#代码隐藏
private void StackPanel_MouseEnter(object sender, MouseEventArgs e)
{
Border sp = sender as Border;
DoubleAnimation db = new DoubleAnimation();
//db.From = 12;
db.To = 150;
db.Duration = TimeSpan.FromSeconds(0.5);
db.AutoReverse = false;
db.RepeatBehavior = new RepeatBehavior(1);
sp.BeginAnimation(StackPanel.HeightProperty, db);
}
private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
{
Border sp = sender as Border;
DoubleAnimation db = new DoubleAnimation();
//db.From = 12;
db.To = 12;
db.Duration = TimeSpan.FromSeconds(0.5);
db.AutoReverse = false;
db.RepeatBehavior = new RepeatBehavior(1);
sp.BeginAnimation(StackPanel.HeightProperty, db);
}
}
您可以使用任何元素控件,如网格、堆栈、停靠、边框……
https://stackoverflow.com/questions/1305065
复制相似问题