Alternative to FindAncestor RelativeSource in Silverlight 4 to bind to a property of the page
Posted
by TimothyP
on Stack Overflow
See other posts from Stack Overflow
or by TimothyP
Published on 2010-05-06T09:36:25Z
Indexed on
2010/05/06
15:28 UTC
Read the original article
Hit count: 1100
Hi,
FindAncestor RelativeSource only supports 'Self' and 'TemplatedParent', but I have to bind the width of a popup to the width of the page.
Giving the page a name causes problems because sometimes it will throw exceptions saying a control with that name is already present in the visual tree.
<Popup IsOpen="True"
Width="{Binding ElementName=BordPage, Path=Width}"
Height="{Binding ElementName=BordPage, Path=Height}">
Background information:
I'm using a SL4 navigation based application here. BordPage is a navigation page, which I'm using multiple times within the application. So giving it a name in the page itself is not really a good idea, but I don't know how else I can bind to the width and height of the page.
What I'm trying to do is have a black border (with opacity 0.8) cover the entire screen, (including the controls of the MainPage). Then on top of that I want to display some other controls.
Since the application is touch controlled, providing the user with a ComboBox to select a value doesn't really work wel. Instead I want to show this black overlay window with a listbox taking up most of the screen so the user can simply touch the value he wants with a single click.
Update: I just realized I can use the ChildWindow class to do this. But my original question remains.
© Stack Overflow or respective owner