I have a WPF UserControl (Foo.xaml) that should be displayed streched (VerticalAlignment="Stretch" HorizontalAlignment="Stretch") on a window.
If I don't specify Width/Height on the UserControl it will be displayed as intended at runtime. Unfortunately the VS WPF designer will not show the control correctly if I open Foo.xaml (size may be 0x0 depending on the child controls).
If I specify a size on the UserControl the designer will work correctly with Foo.xaml but then it won't strech at runtime.
How can I fix this so that it works at design and runtime?
It sounds like your UserControl is only useful if it is a certain minimum size. If so, set the MinWidth and MinHeight properties.
You can set the DesignWidth and DesignHeight properties on the UserControl to adjust the height and width of the control in the design view.
You can adjust those properties with the mouse by dragging the square rectangles that show up when you select the resize tool for the UserControl.
Related
I am trying to bind a TabControl to the size of the MainWindow in WPF. I have done it very easily, but the problem is with padding or margin.
If I just set the both with the same size during the window resize, then the TabControl hangs off the right side of the window by it's border. I have tried playing with padding and margin of the TabControl with no effect on it's over flow of the window.
Should I use a custom converter? My skill with them is pretty novice and am not sure how I would work a two way converter for these properties.
Im writing a WPF application where usercontrols are added to a TabControl at runtime - creating a tab for each user control. The problem then is...these controls can have different width and height which means the tabcontrol must adjust its own width and height accordingly. I tought this would be a simple exercise of just accessing the usercontrols Height/ActualHeight properties, but these are NaN/0.0
Is it not possible to get this information?
I can propose next solution:
When you add a new control to the TabControl (is it a TabControl or a TabItem?) set bindings for the Width and Height properties. Create a converter to convert sizes of added controls to the size of Owner (in case if you need to have minimum size).
ActualWidth and ActualHeight properties perhaps are 0 because control wasn't measured yet. Look this thread
I have a user control and I'm adding to a WinForms panel in an ElementHost. I'm resizing my user control at runtime and want to bind its size with parent ElementHost.
Is this possible? Please provide solution if any.
Set DockStyle.Fill property for ElementHost's Dock property.
i have a DataGrid with FrozenColumnCount set to one and some DataTemplateColumns which contains a control which uses an adorner (simply lets say a TextBox with an Adorner which shows the Text "Unit" or somelike). If I use the HorizontalScrollbar the adorner lays before the fixed column. How can I solve this problem.
This is the nature of Adorners, they will always be on "top".
Anything placed in the adorner layer is rendered on top of the rest of
any styles you have set. In other words, adorners are always visually
on top and cannot be overridden using z-order.
I just added a ScrollViewer to my WPF app. Now some of my content is hidden because it is at the bottom of the ScrollViewer--this is intentional. However, is there any way in the Design view of Visual Studio 2010 to scroll a scrollbar so that I can preview what my app looks like when the scrollbar is at different positions? It would be convenient to check this out without having to build my Solution and run my app, just to scroll down and make sure things look as I expect.
My ScrollViewer is contained in a UserControl that does not have a height set on it. I set my ScrollViewer's height to Auto so all the contents of the ScrollViewer show in Design view in my UserControl--this way, I can see what I'm doing. I set the height of the Window that includes the UserControl, so when I run my app the ScrollViewer is bounded by that Window height, as desired.
I just removed these properties from my UserControl in Visual Studio.
d:DesignHeight and d:DesignWidth
Like yours, my ScrollViewer's height was already set to Auto.