开发者

Problem with "{Binding RelativeSource={RelativeSource FindAncestor

I'm working on a Prism Composite application where I load different views into a region. I need to make sure that the view I'm loading is resized to the same height as the region. Each view is a usercontrol that has a Grid as the outer element. I'm using the following code

    <Grid  Height="{Binding RelativeSource={RelativeSource FindAncestor,
        AncestorType={x:Type ItemsControl}}, Path=ActualHeight}">

To set the height of the grid. My problem is that this exact code works fine for one view and doesn't for another view. On the grid that doesn't开发者_运维百科 work, the height is what I would expect as if the Height property is not being set.

Any suggestions on how to trouble shoot this.


Without knowing much, I'd say this issue really just boils down to a binding issue. Debugging bindings is tricky, but there is a really great article on the subject here: http://www.beacosta.com/blog/?p=52

Use the "diagnostics:PresentationTraceSources.TraceLevel=High" approach that Bea describes and find out what element you are actually binding to by watching the output window. That ought to help figure out why it's failing.

Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜