简单的 WPF 控制问题
在学习使用 WPF 时刚刚遇到了一堆随机但可能非常简单的问题。如果有人能回答其中任何一个,我们将不胜感激。
我有一个根据自己的喜好设计样式的
矩形
,然后是一个StackPanel
,我实际上将内容(一堆标签)放置在其中。它看起来像< code>Rectangle 没有结束语句,那么如何使其成为StackPanel
的父级(我希望面板随之移动)?我需要以表格形式显示文本(标签)。它只有两列和 8 行(行数可能会改变)。我最初考虑只使用
Grid
,但由于这是用于布局的,因此它没有按预期工作。我还查看了 DataGrid,但这对于我的需求来说似乎令人困惑且过于复杂。我可以使用任何简单的表格样式元素吗?我有一些动画扩展器,我想为应用程序中的其他 UI 内容元素提供类似的标题栏。我还没有看到任何类型的元素,所以我想知道我是否只需要使用
Label
或其他东西并将其样式设置为尽可能接近匹配,或者是否已经存在我想要的东西应该使用。如果我需要使用标签,将其与作为标题栏的元素分组/附加的正确方法是什么?WPF 是否存在允许 Mac 样式菜单栏的控件?类似于 ,其中图标在鼠标悬停时移动并展开。
我有一个网格,其中有两个带有
Height="Auto"
的扩展器(一个在另一个上面),并且有两行设置为Height="Auto"
,以便当顶部最小化时,底部会向上移动以缩小间隙。我现在使用MinHeight
来确保它们至少有所扩展,但我想让它们占据Grid
高度的 100%。我应该为此做什么?
Just ran into a bunch of random but probably very simple questions while learning to work with WPF. If anyone can answer any of these it would be most appreciated.
I have a
Rectangle
that I styled to my liking, and then aStackPanel
that I am actually placing the content (bunch of labels) in. It looks likeRectangle
doesn't have a closing statement so how can I make it the parent of theStackPanel
(I want the panel to move with it)?I need to display text (labels) in a table form. It will only be two columns, and 8 rows (row count may change). I initially looked into just using a
Grid
, but as this is a intended for Layouts, it didn't work as expected. I also checked outDataGrid
, but this seems confusing and overly complicated for my needs. Is there any simple Table style element I can use?I have some Animated Expanders and I want to give the other UI content elements in my application a similar looking title bar. I haven't seen any sort of element for this, so I am wondering if I just need to use a
Label
or something and style it as close as possible to match, or if something already exists that I should use instead. If I need to use a label, what is the proper way to group/attach it with the element that it is the title bar for?Do any controls exist for WPF that would allow for a Mac style menu bar? Something similar to where the icons move and expand as they are mouse over.
I have a grid that has two expanders (one above the other) with
Height="Auto"
, and two rows set toHeight="Auto"
so that when the top is minimized, the bottom one moves up to close the gap. I am using aMinHeight
right now to make sure they are at least somewhat expanded, but I would like to make them take up the full 100% of theGrid
height. What should I do for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
矩形不能有子内容,更好的方法可能是使用边框,您可以将其用作堆栈面板的父级,应用背景和 BorderBrush 使其看起来像矩形。
对于简单的表格布局,网格是最佳选择。您的问题是您需要它是动态的吗?如果是这样,您可以在列上使用 SharedSizeGroup 创建多个网格,使它们看起来像单个网格。 参阅:如何沿列/行对齐通过模板创建的单独网格?
了解如何创建您自己的模板!
据我所知,但做起来相对简单,创建一个故事板,在鼠标悬停时缩放项目。
不知道...失去动力!
正如 Andrzej Nosal 提到的,这些确实应该是单独的问题!
A rectangle cannot have child content, a better approach might be to use a Border, you can use this as that parent of your stackpanel, applying a Background and BorderBrush to make it look like a rectangle.
For a simple table layout Grid is the way to go. Is your problem that you need it to be dynamic? If so, you can create multiple grids with SharedSizeGroup on the columns to make them look like a single grid. See: How to align separate Grids created via templates along their columns / rows?
Learn about creating your own templates!
Not that I know of, but it would be relatively simple to do, create a storyboard that scales the item on mouse over.
No idea ... running out of steam!
As Andrzej Nosal mentioned, these really should be separate questions!