简体   繁体   English

简单的WPF控制问题

[英]Simple WPF Control Questions

Just ran into a bunch of random but probably very simple questions while learning to work with WPF. 在学习使用WPF时,只是遇到了一些随机但可能非常简单的问题。 If anyone can answer any of these it would be most appreciated. 如果任何人都可以回答这些问题,将不胜感激。

  1. I have a Rectangle that I styled to my liking, and then a StackPanel that I am actually placing the content (bunch of labels) in. It looks like Rectangle doesn't have a closing statement so how can I make it the parent of the StackPanel (I want the panel to move with it)? 我有一个自己喜欢的Rectangle样式,然后是一个我实际上要放置内容(一堆标签)的StackPanel 。看起来Rectangle没有关闭语句,那么如何使它成为父对象的父对象呢? StackPanel (我希望面板随其一起移动)吗?

  2. I need to display text (labels) in a table form. 我需要以表格形式显示文本(标签)。 It will only be two columns, and 8 rows (row count may change). 它只有两列和8行(行数可能会改变)。 I initially looked into just using a Grid , but as this is a intended for Layouts, it didn't work as expected. 我最初只是考虑使用Grid ,但是由于这是用于Layouts的,因此无法按预期工作。 I also checked out DataGrid , but this seems confusing and overly complicated for my needs. 我还签出了DataGrid ,但是对于我的需求而言,这似乎令人困惑并且过于复杂。 Is there any simple Table style element I can use? 我可以使用任何简单的表格样式元素吗?

  3. I have some Animated Expanders and I want to give the other UI content elements in my application a similar looking title bar. 我有一些Animated Expanders,我想给我的应用程序中的其他UI内容元素添加外观相似的标题栏。 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. 我还没有看到任何这样的元素,所以我想知道是否只需要使用Label或某些东西并对其进行样式设置,使其尽可能接近以匹配,或者是否已经存在应该使用的东西。 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? 如果需要使用标签,将其与标题栏所对应的元素进行分组/附加的正确方法是什么?

  4. Do any controls exist for WPF that would allow for a Mac style menu bar? WPF是否存在允许Mac样式菜单栏的控件? Something similar to 类似于 在此处输入图片说明 where the icons move and expand as they are mouse over. 图标在鼠标悬停时移动和扩展的位置。

  5. I have a grid that has two expanders (one above the other) with Height="Auto" , and two rows set to Height="Auto" so that when the top is minimized, the bottom one moves up to close the gap. 我有一个网格,其中具有两个带有Height="Auto"扩展器(一个在另一个之上),并且两行设置为Height="Auto"以便当顶部最小化时,底部的向上移动以缩小间隙。 I am using a MinHeight right now to make sure they are at least somewhat expanded, but I would like to make them take up the full 100% of the Grid height. 我现在正在使用MinHeight来确保它们至少有所扩展,但是我想使它们占据Grid高度的100%。 What should I do for this? 我该怎么办?

  1. 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. 矩形不能包含子内容,更好的方法可能是使用边框,您可以将其用作堆栈面板的父对象,并应用Background和BorderBrush使其看起来像矩形。

  2. 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. 如果是这样,您可以在列上使用SharedSizeGroup创建多个网格,以使它们看起来像一个网格。 See: How to align separate Grids created via templates along their columns / rows? 请参阅: 如何将通过模板创建的单独网格沿其列/行对齐?

  3. Learn about creating your own templates! 了解有关创建自己的模板的信息!

  4. Not that I know of, but it would be relatively simple to do, create a storyboard that scales the item on mouse over. 并不是我所知道的,但是创建一个情节提要能够在鼠标悬停时缩放项目的故事板相对容易。

  5. No idea ... running out of steam! 不知道...快要筋疲力尽了!

As Andrzej Nosal mentioned, these really should be separate questions! 正如Andrzej Nosal所述,这些确实应该是单独的问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM