绑定到ActualWidth不起作用 [英] Binding to ActualWidth doesn't work

查看:115
本文介绍了绑定到ActualWidth不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码:

< Button Click =" Button_Click_1" Content =" display canvas" /> 
< Canvas x:Name =" _Canvas" Z-索引= QUOT; 4英寸能见度= QUOT;折叠"背景= QUOT;蓝色">
< Border Width =" {Binding ElementName = _Canvas,Path = ActualWidth}" Height =" {Binding ElementName = _Canvas,Path = ActualHeight}"背景= QUOT;黄色" />
< / Canvas>

和:

 private void Button_Click_1(对象发件人,RoutedEventArgs e )
{
_Canvas.Visibility = Visibility.Visible;
}

当我点击按钮时,我会看到整个页面都是黄色背景。 但是,我只看到一个蓝色背景,这意味着边框没有从画布中获取实际宽度和实际高度。 如果我最初看到Canvas,
那么它可以正常工作。问题在于,由于某种原因,可见性导致绑定无法正常工作。


这可以通过RTM修复吗?


... Stefan

解决方案

检查出来。




------------------------------- -------------------------------------------------


Alejandro Campos Magencio - 微软升级工程师 - 论坛版主

 如果我的回复回答了您的问题,请将此帖标记为已回答。


I have this code:

<Button Click="Button_Click_1" Content="display canvas"/>
<Canvas x:Name="_Canvas" ZIndex="4" Visibility="Collapsed" Background="Blue">
    <Border Width="{Binding ElementName=_Canvas, Path=ActualWidth}" Height="{Binding ElementName=_Canvas, Path=ActualHeight}" Background="Yellow"/>
</Canvas>

and:

private void Button_Click_1(object sender, RoutedEventArgs e)
{
    _Canvas.Visibility = Visibility.Visible;
}

when I click the button I should see the whole page with a yellow background.  However, I simply see a blue background which means the border is not picking up actualwidth and actualheight from the Canvas.  If I make the Canvas initially visible, then it works correctly. The problem is that for some reason the visibility is causing the binding to not work correctly.

Can this please be fixed by RTM?

...Stefan

解决方案

Checking this out.


--------------------------------------------------------------------------------

Alejandro Campos Magencio - Microsoft Escalation Engineer - Forum Moderator
 If my reply answers your question, please mark this post as answered.


这篇关于绑定到ActualWidth不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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