简体   繁体   English

WPF控制问题

[英]WPF Control Questions

I just switched over to WPF from just regular C# .NET for the more advanced UI design controls. 我只是从常规C#.NET切换到WPF,以使用更高级的UI设计控件。 I have managed to become extremely confused over what should be extremely simple, and I hope someone can help. 我已经对应该非常简单的内容感到非常困惑,希望有人能提供帮助。

Basically I want to have sections on either side (for the most part these will be list-boxes inside of expanders), one list-box in the bottom-middle, and then a large rich text box taking up the middle. 基本上,我想在每一侧都有部分(大多数情况下是扩展器内部的列表框),在底部的中间有一个列表框,然后是一个占据中间的大型富文本框。

My understanding was that I could just take a DockPanel, set the ChildFill to true, dock each one where it should go, and leave the last one to fill the space. 我的理解是,我可以只使用一个DockPanel,将ChildFill设置为true,将每个应该停靠的位置停靠,然后保留最后一个以填充空间。 The list boxes alone don't seem to work at with the DockPanel, and the DockPanel does not seem to expand when I change the size of the window. 仅列表框似乎不适用于DockPanel,并且当我更改窗口大小时,DockPanel似乎不会扩展。

So basically my questions are... 所以基本上我的问题是...

1) Why does the DockPanel not expand/shrink when I change the size of the window? 1)更改窗口大小时,为什么DockPanel无法扩展/缩小?

2) Buttons seem to work fine in the Dock Panel (like all of the examples I found) but using List Boxes instead does not seem to work properly. 2)按钮在Dock面板中似乎工作正常(就像我发现的所有示例一样),但是使用列表框似乎无法正常工作。 Why is this? 为什么是这样?

3) If I put the list boxes inside of Expanders instead, if I have say two of these on the left side, and I shrink the top expander, will the bottom expander grow upwards to fill the gap? 3)如果我将列表框放到扩展器的内部,如果我在左侧说了两个,然后收缩顶部扩展器,底部扩展器会向上增长以填补空白吗?

I can't really afford anything like ActiPro, and I was not able to get the AvalonDock controls to show up on the MSVC 2010 toolbar, so I am pretty much stuck using the default controls. 我真的买不起ActiPro,而且我也无法让AvalonDock控件显示在MSVC 2010工具栏上,因此我在使用默认控件时非常困惑。

1). 1)。 I have just tested the DockPanel and it does expand / shrink when the Window is resized - Have you removed the Grid that is placed in the Window by default in Visual Studio? 我刚刚测试了DockPanel,当调整窗口大小时,它确实会扩展/收缩-您是否已删除Visual Studio中默认情况下放置在窗口中的网格? If you mean it doesn't resize proportionally to the Windows size then i think you will need to use a Grid. 如果您的意思是不按Windows大小按比例调整大小,那么我认为您将需要使用网格。

2). 2)。 Again, list boxes work fine for me - Can you provide some more detail explaining why they don't work properly? 同样,列表框对我来说很好用-您能否提供更多详细信息来说明为什么它们不能正常工作?

3). 3)。 It depends on what you mean by "Grow upwards". 这取决于您所说的“向上增长”的意思。 If the top expander is closed, only the header will be displayed and the bottom expander will move up to take the space taken by the first expanders content (this is the default behaviour). 如果关闭顶部扩展器,则仅显示标题,而底部扩展器将向上移动以占据第一个扩展器内容所占用的空间(这是默认行为)。

Do you have some XAML you can post as this will help identify your problems. 您是否可以发布一些XAML,因为这将帮助您确定问题。

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

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