WPF网格布局问题 [英] WPF Grid Layout Issue

查看:94
本文介绍了WPF网格布局问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道是否有人可以帮助我,

我正在使用WPF(使用C#2010)构建Windows应用程序的过程

因为我正在使用RibbonWindow-我的整个UI都在网格中运行-我相信由于Ribbon而我必须这样做

在构建UI的过程中-我遇到了一个问题.

我的UI看起来与Outlook 2007非常相似-因此,我有一个功能区工具栏,在它下面的新网格行中是屏幕左侧的Treeview控件.我的网格的这一行有两列.

现在我的问题来了,我希望用户能够在左侧显示的树状视图中选择项目,并在右侧窗口(或第二个网格"列)中动态显示控件/内容.我可以在网格"列中放置用户控件吗?

在Outlook UI中-如果用户选择收件箱",则UI的中间列将显示电子邮件的用户"列表.如果用户随后更改并选择日历,则UI会删除电子邮件列表,并将其替换为日历列表.这是我尝试使用WPF实现的功能.我毫不怀疑这是可以做到的-但是WPF是新手,因此仍然习惯于通用的UI设计和布局等.

任何对此的指导将不胜感激

非常感谢您的提前帮助
Dan

Wonder if someone can help me,

I''m in the process of building a Windows application using WPF (with C# 2010)

Because I''m using the RibbonWindow - my entire UI is running in a Grid - which I beleive I must do owing to the Ribbon

In the process of building my UI - I''ve encountered an issue.

My UI looks very similar to Outlook 2007 - as such, I have a Ribbon Toolbar, underneath this, in a new Grid Row, is a Treeview control on the left hand side of the screen. I have this row of the Grid with two columns.

My issue now comes, I want the User to be able to select items in my treeview displayed on the lefthandside, and dynamically display controls/content in the Right hand window (or the second Grid column). Is there a User Control I can place in the Grid Column to do this?

In the Outlook UI - if the User selects Inbox - the middle column of the UI displays the Users list of emails. If the User then changes and selects Calendar, the UI then removes the List of Emails and replaces this with the Calendar list. This is the kind of functionality I am trying to acheive using WPF. I have no doubt this can be done - but am new to WPF so am still getting used to general UI design and layouts etc..

Any guidance on this would be greatly appreciated

Many thanks for your help in advance
Dan

推荐答案

当然,您可以将Usercontrol放置在网格中的任何位置.

假设您要将网格放置在Tree节点的SelectionChanged的第1行,第1列,请使用:

Of course, you can put an Usercontrol anywhere in the Grid.

Say you want to place the Grid at Row 1, Column 1, on SelectionChanged of Tree node, use :

yourGrd.Children.Add(yourusercontrol);
Grid.SetRow(yourusercontrol, 1);
Grid.SetColumn(yourusercontrol, 1);




这将起作用.您的用户控件将放置在正确的位置.




This will work. Your usercontrol will be placed on correct location.


这篇关于WPF网格布局问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆