Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4122622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:30:19+00:00 2026-05-20T23:30:19+00:00

I can’t get my application to resize the screen correctly. here is my xaml

  • 0

I can’t get my application to resize the screen correctly. here is my xaml

<Grid x:Name="LayoutRoot"
      Background="White"
      DataContext="{Binding Source={StaticResource ViewModel}}"
      MinHeight="473"
      MinWidth="1200"
      MaxHeight="600"
      MaxWidth="1366">
<i:Interaction.Triggers>
    <i:EventTrigger EventName="SizeChanged">
        <ei:CallMethodAction MethodName="WndSizeChanged"
                             TargetObject="{Binding}" />
    </i:EventTrigger>
</i:Interaction.Triggers>

    <Grid.ColumnDefinitions>
        <ColumnDefinition  Width="300*" />
        <ColumnDefinition  Width="189*" />
        <ColumnDefinition  Width="720*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition  Height="101*" />
        <RowDefinition  Height="372*" />
    </Grid.RowDefinitions>

 <sdk:DataGrid Grid.Row="1"
                  Grid.Column="0"
                  Grid.ColumnSpan="3"
                  AutoGenerateColumns="False"
                  HorizontalAlignment="Left"
                  Height="Auto"
                  Width="Auto"
                  Name="dataGrid_Columns"
                  VerticalAlignment="Top"
                  ItemsSource="{Binding Path=LstDetails}"
                  RowDetailsVisibilityMode="VisibleWhenSelected"
                  IsReadOnly="True"
                  HeadersVisibility="All"
                  HorizontalScrollBarVisibility="Visible"
                  VerticalScrollBarVisibility="Visible"
                  CanUserReorderColumns="True"
                  CanUserResizeColumns="True"
                  CanUserSortColumns="True">

       .....more code nested in here.......
   </sdk:DataGrid>

I have tried putting auto on the user control, and also in the grid, nothing is working. If I take out thet min and max, then it goes off the page. That event I put on there, only fires after you resize it. I would assume because this is a user control inside a shell. I am using prism. I found an example to detect the height and width, but it doesn’t work initially. When I bind the height and width to double properties, then the event never fires at all. I am running out of ideas. I have found ways to put in code behind the actual width and height. I really want to avoid code behind, but even that did not work. I know the problem has to do with the datagrid, because this is dynamic and will grow or shrink based on filters. Any help is greatly appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:30:20+00:00Added an answer on May 20, 2026 at 11:30 pm

    This is the best solution I can come up with. It works, but probably not nice since the VM now knows something about the View (correct me if I am wrong). so here is my VM:

        public void WndSizeChanged(object sender, EventArgs e)
        {
            this.setHeightWidth();
        }
        private void setHeightWidth()
        {
            this.WindowHeight = (Application.Current.RootVisual as FrameworkElement).ActualHeight - 125;
            this.WindowWidth = (Application.Current.RootVisual as FrameworkElement).ActualWidth - 108;
        }
    
        public double WindowHeight{get;set;}
    
        public double WindowWidth{get;set;}
    

    and in my view:

    <Grid x:Name="LayoutRoot"
          Background="White"
          DataContext="{Binding Source={StaticResource ViewModel}}"
          Height="{Binding Path=WindowHeight, Mode=TwoWay}"
          Width="{Binding Path=WindowWidth, Mode=TwoWay}">
    
            <i:Interaction.Triggers>
            <i:EventTrigger EventName="LayoutUpdated">
                    <ei:CallMethodAction MethodName="WndSizeChanged"
                                         TargetObject="{Binding}" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
    
            <Grid.ColumnDefinitions>
                <ColumnDefinition  Width="300*" />
                <ColumnDefinition  Width="189*" />
                <ColumnDefinition  Width="720*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition  Height="101*" />
                <RowDefinition  Height="372*" />
            </Grid.RowDefinitions>
    

    Basically changed the event that is triggered to be LayoutUpdated. Works like a charm. I am on a time-line so this will have to do. I hope this will help anyone who is in a similar situation as me. Don’t forget to call setHeightWidth() in the constructor to set the h and w initially as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I get a 'when to use' for these and others? <% %> <%#
Can I use the following across all browsers? <a href=# onclick=doSomething()>Click here.</a> Is this
Can i get the source code for a WAMP stack installer somewhere? Any help
I need to solve the following question which i can't get to work by
Can anybody please tell me how to get ReSharper to replace multiple instances (instead
Can't seem to get the Back Button to appear in a UINavigationController flow. I
Can somebody point me to a resource that explains how to go about having
Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of
Can you cast a List<int> to List<string> somehow? I know I could loop through
can you recommend some good ASP.NET tutorials or a good book? Should I jump

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.