2

I write client under WPF. The bottom line is this: on the left, the tabs panel on the right is the Grid which changes when the tabs change, when I click, I see two ways to change:

  1. Using TabControl. But then the whole application will essentially be in one .xaml / .cs file. I do not want to have everything in one file

2.Using

int index = ListViewMenu.SelectedIndex;
MoveCursorMenu(index);

switch (index)
{
    case 0:
        GridPrincipal.Children.Clear();
        GridPrincipal.Children.Add(new UserControlHome());
        break;
    case 1:

Each tab has an id; when clicked, the display field changes to the right. That is, the current one is deleted and the window that is in another file is loaded. That is, for each tab its own file. It is very convenient for me, but the fact is that these windows, which will be loaded, I ask hard through the Height Width. On the main tabbed page I use Margin

<Grid Margin="250 55 0 0">
    <Grid x:Name="GridPrincipal" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>

It turns out that when you change the scale of the window to keep the proportions will not work when using 2 options. How to fix it?

+UPDATE:

I have(e.g.)

MainWindow

UserControl

MainWindow loaded UserControl

if I want to stretch the window, the nested element is not stretched

Stretching MainWindow with embeded UserControl

How to fix it?

RookieCPP
  • 83
  • 7
  • I advise not to use major margin to set position of controls. It won't make UI responsive. Why you take `Grid` within `Grid` and only use it as container? Please provide more details on design you developed and design you need. – Gaurang Dave Jun 17 '19 at 07:41
  • The answer was in the Grid MainWindowl - I had set the HorizointalAlignment to Left and VerticalAlignment to Left, setting these to Stretch resolved the issue and set "auto" to Height and Width in your UserControl. – RookieCPP Jun 17 '19 at 08:15

0 Answers0