I think that if you remove the Width, Height, Margin, VerticalAlignment, HorizontalAlignment attributes of user control, scroll viewer and grids, then the user control and scroll viewer will occupy the whole area of tab item automatically.
Binding to grid size from UserControl
Hello,
I have a TabControl and a TabItem inside it. Inside the TamItem is a Grid named "xml_grid_004" and inside the Grid "xml_grid_004" is a UserControl - see the PICTURE-1 below.
So, how can I obtain the width and height of "xml_grid_004" in UserControl using Binding ? If I use classic binding to Width and Height to parent of the UserControl (it is, indeed, the "xml_grid_004") the UserControl Width and Height is equal to Zero at design time - see the PICTURE-2 and I do not see the UserControl. Complette source code is here:
https://drive.google.com/file/d/16mYZWndd7nrswWn9W8yf5XU8pPRoqhrb/view?usp=sharing
How can I transfer the "xml_grid_004" Width and Height to my UserControl ???? to be visible in VisualDesigner at design time ? Is it possible ?
PICTURE-1:
PICTURE-2:
Developer technologies Windows Presentation Foundation
2 additional answers
Sort by: Most helpful
-
DaisyTian-1203 11,646 Reputation points
2021-05-31T02:53:38.95+00:00 It is impossible to transfer
xml_grid_004
Width and Height toUserControl1
to be visible in VisualDesigner at design time with binding other windows's elements properties value.
Reason 1: The Visual Studio can't find thexml_grid_004
at design time ,xml_grid_004
is inMainWindow
. There is no info to tellUserControl1
thatxml_grid_004
is inMainWindow
, soUserControl1
can't findxml_grid_004
.
Reason 2:ActualWidth/ActualHeight
gets the rendered width/height of this element. The element should be rendered, ActualWidth and ActualHeight are not rendered at design time.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. -
JerryM 1,131 Reputation points
2021-05-31T18:12:18.99+00:00 hm I am very sad and frightened ... as usually ... if MS things are concerned..
on the other hands .. both replies seems to be ok ..