在mouseleftbuttonup上使用gridsplitter来折叠&展开菜单栏(Expression Blend 3,silverlight) [英] Using gridsplitter on mouseleftbuttonup to Collapse & expand menu column (Expression Blend 3, silverlight)

查看:73
本文介绍了在mouseleftbuttonup上使用gridsplitter来折叠&展开菜单栏(Expression Blend 3,silverlight)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图找到一个简单的解决方案,当你点击网格探测器时展开和折叠一个网格列。

任何指针?


我的问题似乎是设置列的宽度要求col.width与GridLength属性兼容,但我无法弄清楚类型??

^ _ ^

Hi,

I am trying to find a simple solution to expand and collapse a grid column when you click on the gridsplitter.

Any pointers?


My problem seems to be setting the width of the column requires col.width to be compatible with the GridLength property, but I can't figure out the type??

^_^

推荐答案

我今晚玩了这个问题一段时间,也许我有一些建议可以帮助你。

首先,您可能已经知道通过更改网格列的宽度定义,可以使列折叠。您所要做的就是将宽度设置为0.假设您为网格列创建了名称,如下所示:


I played with this problem for a little while tonight, and perhaps I have some suggestions that can help you out.

First, you probably already know that by changing the grid column's width definition, you can make the column collapse.  All you have to do is set the width to 0.  Let's say you created names for your grid's columns, as below:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Name="column1" />
        <ColumnDefinition Name="column2" />
        <ColumnDefinition Name="column3" />
    </Grid.ColumnDefinitions>
</Grid>


然后在代码后面,您可以使用以下内容使列消失:


Then in code behind, you can make a column disappear with the following:

column3.Width = new GridLength(0);


所以下一个问题是,当你点击GridSplitter时你是如何做到的?不幸的是,我不知道 的答案,但我有一个可能的解决方案。在您的XAML中,为PreviewMouseLeftButtonDown和PreviewMouseLeftButtonUp声明隧道事件(因为我不知道如何处理点击)。要模拟点击,你需要确保mousedown和mouseup出现在同一个元素上 - 如果没有,不要做任何事情。如果是这样,那么在PreviewMouseLeftButtonUp处理程序中,您可以使用我在上面输入的代码隐藏。

请回复并告诉我这是如何工作的。

So the next question is, how do you do this when you click on the GridSplitter?  Unfortunately, I don't know the answer, but I have a possible solution.  In your XAML, declare tunneling events for PreviewMouseLeftButtonDown and PreviewMouseLeftButtonUp (since I don't know how to deal with clicks).  To simulate a click you'll want to make sure that mousedown and mouseup occur on the same element -- if not, don't do anything.  If so, then in the PreviewMouseLeftButtonUp handler you can use the code-behind I entered above.

Please reply and let me know how this works for you.


这篇关于在mouseleftbuttonup上使用gridsplitter来折叠&amp;展开菜单栏(Expression Blend 3,silverlight)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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