3
votes

I have a WPF application that often hangs (becomes completely unresponsive) when the main window is maximized and a particular tab is visible and on top in my tab control. When the window is restored down, it works like charm. What can I do to fix this?

The tab in question has a lot of controls (textboxes, images, buttons, comboboxes gridsplitters, textblocks, datagrid) and I'm doing a lit with the events from these various fields so it's a very "busy" grid.

It sounds similar to the following problem which was unresolved: WPF Datagrids freeze when windows maximized (http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/4641d825-cf80-4b76-a4f9-14183bb72bb2#58dc7fdf-b43c-4782-833f-1d90401f1914)

Let me wrap up with saying that I've not designed the application as I should have and have over 3000 lines of code in the main window. I probably should have created these busy forms as user controls. Is this causing my problems?

   <TabItem Header="Details" Name="tabDetails" Visibility="Collapsed" Width="125" TabIndex="0">
        <!--<ScrollViewer HorizontalAlignment="Stretch" Name="svrDetails" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">-->
        <Grid Name="grdDetails">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="548*" />
                    <ColumnDefinition Width="220*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="326*" />
                    <RowDefinition Height="174" />
                </Grid.RowDefinitions>
                <GridSplitter Name="gspDetailsColumns" Width="10" Grid.Column="0" ResizeDirection="Columns" TabIndex="420" />
                <GridSplitter Name="gspDetailsRows" Width="Auto" Grid.Row="0" Grid.ColumnSpan="2" ResizeDirection="Rows" Grid.Column="0" Height="10" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" TabIndex="410" />
                <ComboBox Height="52" Margin="6,6,6,0" Name="cbxStatus" VerticalAlignment="Top" Cursor="Arrow" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="26" Background="#FFF0F0F0" Grid.Column="1" SelectionChanged="cbxStatus_SelectionChanged" SelectedIndex="0" TabIndex="280">                        
                    <ComboBoxItem Content="Select status..." FontSize="20" FontStyle="Italic" />
                    <ComboBoxItem Content="Active"/>
                    <ComboBoxItem Content="Inactive" />
                    <ComboBoxItem Content="Closed" />
                </ComboBox>
                <Label Height="28" HorizontalAlignment="Left" Margin="119,78,0,0" Name="lblGuid" VerticalAlignment="Top" Visibility="Hidden" Grid.Column="1" />
                <GroupBox Header="Info" HorizontalAlignment="Stretch" Margin="6,64,0,12" Name="gbxInfo" VerticalAlignment="Stretch" Grid.Column="1">
                    <Grid>
                        <!--<TextBox HorizontalAlignment="Stretch" Name="tbkImportant" Text="" VerticalAlignment="Stretch" TextWrapping="Wrap" IsReadOnly="True" Background="#FFF0F0F0" IsTabStop="False" IsUndoEnabled="False" />-->
                    <TextBlock HorizontalAlignment="Stretch" Name="tbkImportant" VerticalAlignment="Stretch" Background="#FFF0F0F0" TextWrapping="Wrap" />
                </Grid>
                </GroupBox>
                <Grid Grid.Row="1" Name="grdDetailsNotesMacro" Grid.ColumnSpan="2">
                    <GroupBox Header="Notes" Name="gbxNotes" >
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="484*" />
                                <ColumnDefinition Width="266*" />                                        
                            </Grid.ColumnDefinitions>                                    
                            <TextBox GotFocus="tbxTag_GotFocus" LostFocus="tbxTag_LostFocus" Height="23" Margin="6,6,6,35" Name="tbxTag" VerticalAlignment="Bottom" Grid.Column="1" Foreground="Gray" Text="[Add tags so to make finding notes easy]" TabIndex="350" />
                            <TextBox GotFocus="tbxNote_GotFocus" LostFocus="tbxNote_LostFocus" Grid.Column="1" Margin="6,6,6,57" Name="tbxNote" Text="[Add notes, comments, or remarks relating to this contact]" Foreground="Gray" TextWrapping="Wrap" SelectionBrush="#9B16181A" VerticalScrollBarVisibility="Auto" TabIndex="340" />
                            <Button Content="Submit" Grid.Column="1" Height="23" HorizontalAlignment="Right" Margin="0,0,128,6" Name="btnSubmit" VerticalAlignment="Bottom" Width="75" Click="btnSubmit_Click" TabIndex="360" />                                    
                            <Button Content="Cancel" Grid.Column="1" Height="23" HorizontalAlignment="Right" Margin="0,0,43,6" Name="btnCancelNote" VerticalAlignment="Bottom" Width="75" Click="btnCancelNote_Click" TabIndex="370" />
                            <DataGrid IsReadOnly="True" AutoGenerateColumns="False" Margin="6,6,0,35" Name="dtgNotes" ItemsSource="{Binding}" AlternatingRowBackground="#33000000" RowBackground="#24000000" VerticalGridLinesBrush="#00000000" ClipboardCopyMode="IncludeHeader" CanUserDeleteRows="True" CanUserAddRows="True" GridLinesVisibility="Horizontal" AreRowDetailsFrozen="True" BorderBrush="#B7000000" CanUserReorderColumns="False">
                                <DataGrid.Columns>
                                <DataGridTextColumn Header="Date" Binding="{Binding Path=Date, StringFormat={}{0:dd/MM/yyyy}}" SortDirection="Descending" />
                                <DataGridTextColumn Header="Author" Binding="{Binding Path=Author}" />
                                <DataGridTextColumn Header="Tags" Binding="{Binding Path=Tags}" />
                                <DataGridTextColumn Header="Notes" Binding="{Binding Path=Notes}"/>
                                </DataGrid.Columns>
                            </DataGrid>
                            <ComboBox Height="23" IsEditable="True" Margin="6,0,160,6" Name="cbxFilter" VerticalAlignment="Bottom" TabIndex="380" Tag="What is a tag?" />                                    
                            <Button Content="Filter" Height="23" HorizontalAlignment="Right" Margin="0,0,81,6" Name="btnFilter" VerticalAlignment="Bottom" Width="75" Click="btnFilter_Click" TabIndex="390" />
                        <Button Content="Clear" Height="23" HorizontalAlignment="Right" Margin="0,0,0,6" Name="btnClearFilter" VerticalAlignment="Bottom" Width="75" Click="btnClearFilter_Click" TabIndex="400" />
                    </Grid>
                    </GroupBox>
                </Grid>
                <ScrollViewer Margin="0,0,10,10" HorizontalAlignment="Stretch" Name="svrDetailsFull" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                    <Grid Name="grdDetailsFullPanel" Grid.Column="0" Grid.Row="0" Margin="0,0,6,6">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="150*" />
                        </Grid.ColumnDefinitions>
                    <Grid Name="grdDetailsPanel">
                            <TextBox LostFocus="tbxNameContent_LostFocus" GotFocus="tbxNameContent_GotFocus" Background="#00000000" BorderBrush="#00000000" FontSize="24" FontWeight="ExtraBold" Height="52" HorizontalAlignment="Center" Margin="10,10,2,0" Name="tbxNameContent" VerticalAlignment="Top" Width="328" MouseEnter="tbxNameContent_MouseEnter" MouseLeave="tbxNameContent_MouseLeave" Text="[Enter name here]" Foreground="Gray" TabIndex="10" />
                            <TextBox GotFocus="tbxAddressContent_GotFocus" Background="#00000000" BorderBrush="#00000000" Height="28" HorizontalAlignment="Center" Margin="10,68,2,0" Name="tbxAddressContent" VerticalAlignment="Top" Width="328" TextChanged="tbxAddressContent_TextChanged" LostFocus="tbxAddressContent_LostFocus" MouseLeave="tbxAddressContent_MouseLeave" MouseEnter="tbxAddressContent_MouseEnter" Foreground="Gray" Text="[Enter address here]" TabIndex="20" />
                            <ComboBox Height="28" HorizontalAlignment="Center" HorizontalContentAlignment="Center" IsEditable="False" Margin="10,136,2,0" Name="cbxType" SelectedIndex="0" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="328" TabIndex="30" LostFocus="cbxType_LostFocus">
                                <ComboBoxItem Content="This is a..." />
                                <ComboBoxItem Content="Laufhaus" />
                                <ComboBoxItem Content="Club" />
                                <ComboBoxItem Content="Studio" />
                                <ComboBoxItem Content="Nightclub" />
                                <ComboBoxItem Content="Generic brothel" />
                                <ComboBoxItem Content="Person" />
                            </ComboBox>
                            <Label Content="" FontStyle="Italic" Height="28" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" Margin="10,102,2,0" Name="lblCoord" VerticalAlignment="Top" VerticalContentAlignment="Top" FontSize="10" />
                            <TextBox MouseEnter="tbxMore_MouseEnter" MouseLeave="tbxMore_MouseLeave" Height="28" HorizontalAlignment="Center" Margin="169,170,44,0" Name="tbxMore" VerticalAlignment="Top" Width="204" LostFocus="tbxMore_LostFocus" TabIndex="50" />
                        <Button Content="x" Height="28" Margin="317,170,6,0" Name="btnClearMore" VerticalAlignment="Top" Background="#00000000" FontWeight="Bold" Foreground="#BC000000" Padding="0" HorizontalAlignment="Center" Width="17" VerticalContentAlignment="Center" Click="btnClearMore_Click" TabIndex="60" />
                        <ComboBox Height="28" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Margin="10,170,216,0" Name="cbxOther" SelectedIndex="0" Text="" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="114" SelectionChanged="cbxOther_SelectionChanged" TabIndex="40" ItemsSource="{Binding Path=comboList}" GotFocus="cbxOther_GotFocus">
                                <!--<ComboBoxItem Content="More info..." />
                                <ComboBoxItem Content="Email" />
                                <ComboBoxItem Content="Email 2" />
                                <ComboBoxItem Content="Mobile" />
                                <ComboBoxItem Content="Telephone" />
                                <ComboBoxItem Content="Address 2" />
                                <ComboBoxItem Content="Nationality" />
                                <ComboBoxItem Content="Works at" />-->
                            </ComboBox>
                            <TextBox MouseEnter="tbxMore2_MouseEnter" MouseLeave="tbxMore2_MouseLeave" Height="28" HorizontalAlignment="Center" Margin="130,204,6,0" Name="tbxMore2" VerticalAlignment="Top" Width="204" Visibility="Collapsed" TabIndex="80" />
                        <Button Visibility="Hidden" Click="btnClearMore2_Click" Content="x" Height="28" Margin="317,204,6,0" Name="btnClearMore2" VerticalAlignment="Top" Background="#00000000" FontWeight="Bold" Foreground="#BC000000" Padding="0" HorizontalAlignment="Center" Width="17" VerticalContentAlignment="Center" TabIndex="90" />
                        <ComboBox ItemsSource="{Binding Path=comboList}" Height="28" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Margin="10,204,216,0" Name="cbxOther2" SelectedIndex="0" Text="" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="114" Visibility="Collapsed" SelectionChanged="cbxOther2_SelectionChanged" TabIndex="70">
                                <!--<ComboBoxItem Content="More info..." />
                                <ComboBoxItem Content="Email" />
                                <ComboBoxItem Content="Email 2" />
                                <ComboBoxItem Content="Mobile" />
                                <ComboBoxItem Content="Telephone" />
                                <ComboBoxItem Content="Address 2" />
                                <ComboBoxItem Content="Nationality" />
                                <ComboBoxItem Content="Works at" />-->
                            </ComboBox>
                            <TextBox MouseEnter="tbxMore3_MouseEnter" MouseLeave="tbxMore3_MouseLeave" Height="28" HorizontalAlignment="Center" Margin="130,238,6,0" Name="tbxMore3" VerticalAlignment="Top" Width="204" Visibility="Collapsed" TabIndex="110" />
                        <Button Visibility="Hidden" Click="btnClearMore3_Click" Content="x" Height="28" Margin="317,238,6,0" Name="btnClearMore3" VerticalAlignment="Top" Background="#00000000" FontWeight="Bold" Foreground="#BC000000" Padding="0" HorizontalAlignment="Center" Width="17" VerticalContentAlignment="Center" TabIndex="120" />
                        <ComboBox ItemsSource="{Binding Path=comboList}" SelectionChanged="cbxOther3_SelectionChanged" Height="28" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Margin="10,238,216,0" Name="cbxOther3" SelectedIndex="0" Text="" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="114" Visibility="Collapsed" TabIndex="100">
                                <!--<ComboBoxItem Content="More info..." />
                                <ComboBoxItem Content="Email" />
                                <ComboBoxItem Content="Email 2" />
                                <ComboBoxItem Content="Mobile" />
                                <ComboBoxItem Content="Telephone" />
                                <ComboBoxItem Content="Address 2" />
                                <ComboBoxItem Content="Nationality" />
                                <ComboBoxItem Content="Works at" />-->
                            </ComboBox>
                            <TextBox MouseEnter="tbxMore4_MouseEnter" MouseLeave="tbxMore4_MouseLeave" Height="28" HorizontalAlignment="Center" Margin="130,272,6,0" Name="tbxMore4" VerticalAlignment="Top" Width="204" Visibility="Collapsed" TabIndex="140" />
                        <Button Visibility="Hidden" Click="btnClearMore4_Click" Content="x" Height="28" Margin="317,272,6,0" Name="btnClearMore4" VerticalAlignment="Top" Background="#00000000" FontWeight="Bold" Foreground="#BC000000" Padding="0" HorizontalAlignment="Center" Width="17" VerticalContentAlignment="Center" TabIndex="150" />
                        <ComboBox ItemsSource="{Binding Path=comboList}" SelectionChanged="cbxOther4_SelectionChanged" Height="28" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Margin="10,272,216,0" Name="cbxOther4" SelectedIndex="0" Text="" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="114" Visibility="Collapsed" TabIndex="130">
                                <!--<ComboBoxItem Content="More info..." />
                                <ComboBoxItem Content="Email" />
                                <ComboBoxItem Content="Email 2" />
                                <ComboBoxItem Content="Mobile" />
                                <ComboBoxItem Content="Telephone" />
                                <ComboBoxItem Content="Address 2" />
                                <ComboBoxItem Content="Nationality" />
                                <ComboBoxItem Content="Works at" />-->
                            </ComboBox>
                            <TextBox MouseEnter="tbxMore5_MouseEnter" MouseLeave="tbxMore5_MouseLeave" Height="28" HorizontalAlignment="Center" Margin="130,306,6,0" Name="tbxMore5" VerticalAlignment="Top" Width="204" Visibility="Collapsed" TabIndex="170" />
                        <Button Visibility="Hidden" Click="btnClearMore5_Click" Content="x" Height="28" Margin="317,306,6,0" Name="btnClearMore5" VerticalAlignment="Top" Background="#00000000" FontWeight="Bold" Foreground="#BC000000" Padding="0" HorizontalAlignment="Center" Width="17" VerticalContentAlignment="Center" TabIndex="180" />
                        <ComboBox ItemsSource="{Binding Path=comboList}" SelectionChanged="cbxOther5_SelectionChanged" Height="28" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Margin="10,306,216,0" Name="cbxOther5" SelectedIndex="0" Text="" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="114" Visibility="Collapsed" TabIndex="160">
                                <!--<ComboBoxItem Content="More info..." />
                                <ComboBoxItem Content="Email" />
                                <ComboBoxItem Content="Email 2" />
                                <ComboBoxItem Content="Mobile" />
                                <ComboBoxItem Content="Telephone" />
                                <ComboBoxItem Content="Address 2" />
                                <ComboBoxItem Content="Nationality" />
                                <ComboBoxItem Content="Works at" />-->
                            </ComboBox>
                            <TextBox MouseEnter="tbxMore6_MouseEnter" MouseLeave="tbxMore6_MouseLeave" Height="28" HorizontalAlignment="Center" Margin="130,340,6,0" Name="tbxMore6" VerticalAlignment="Top" Width="204" Visibility="Collapsed" TabIndex="200" />
                        <Button Visibility="Hidden" Click="btnClearMore6_Click" Content="x" Height="28" Margin="317,340,6,0" Name="btnClearMore6" VerticalAlignment="Top" Background="#00000000" FontWeight="Bold" Foreground="#BC000000" Padding="0" HorizontalAlignment="Center" Width="17" VerticalContentAlignment="Center" TabIndex="210" />
                        <ComboBox ItemsSource="{Binding Path=comboList}" SelectionChanged="cbxOther6_SelectionChanged" Height="28" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Margin="10,340,216,0" Name="cbxOther6" SelectedIndex="0" Text="" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="114" Visibility="Collapsed" TabIndex="190">
                                <!--<ComboBoxItem Content="More info..." />
                                <ComboBoxItem Content="Email" />
                                <ComboBoxItem Content="Email 2" />
                                <ComboBoxItem Content="Mobile" />
                                <ComboBoxItem Content="Telephone" />
                                <ComboBoxItem Content="Address 2" />
                                <ComboBoxItem Content="Nationality" />
                                <ComboBoxItem Content="Works at" />-->
                            </ComboBox>
                            <TextBox Height="28" HorizontalAlignment="Center" Margin="130,374,6,0" Name="tbxMore7" VerticalAlignment="Top" Width="204" Visibility="Collapsed" TabIndex="230" />
                        <Button MouseEnter="btnClearMore7_MouseEnter" MouseLeave="btnClearMore7_MouseLeave" Visibility="Hidden" Click="btnClearMore7_Click" Content="x" Height="28" Margin="317,374,6,0" Name="btnClearMore7" VerticalAlignment="Top" Background="#00000000" FontWeight="Bold" Foreground="#BC000000" Padding="0" HorizontalAlignment="Center" Width="17" VerticalContentAlignment="Center" TabIndex="240" />
                        <ComboBox ItemsSource="{Binding Path=comboList}" SelectionChanged="cbxOther7_SelectionChanged" Height="28" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Margin="10,374,216,0" Name="cbxOther7" SelectedIndex="0" Text="" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="114" Visibility="Collapsed" TabIndex="220">
                                <!--<ComboBoxItem Content="More info..." />
                                <ComboBoxItem Content="Email" />
                                <ComboBoxItem Content="Email 2" />
                                <ComboBoxItem Content="Mobile" />
                                <ComboBoxItem Content="Telephone" />
                                <ComboBoxItem Content="Address 2" />
                                <ComboBoxItem Content="Nationality" />
                                <ComboBoxItem Content="Works at" />-->
                            </ComboBox>
                            <TextBox Height="28" HorizontalAlignment="Center" Margin="130,408,6,0" Name="tbxMore8" VerticalAlignment="Top" Width="204" Visibility="Collapsed" TabIndex="260" />
                        <Button MouseEnter="btnClearMore8_MouseEnter" MouseLeave="btnClearMore8_MouseLeave" Visibility="Hidden" Click="btnClearMore8_Click" Content="x" Height="28" Margin="317,408,6,0" Name="btnClearMore8" VerticalAlignment="Top" Background="#00000000" FontWeight="Bold" Foreground="#BC000000" Padding="0" HorizontalAlignment="Center" Width="17" VerticalContentAlignment="Center" TabIndex="270" />
                        <ComboBox ItemsSource="{Binding Path=comboList}" Height="28" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Margin="10,408,216,0" Name="cbxOther8" SelectedIndex="0" Text="" VerticalAlignment="Top" VerticalContentAlignment="Center" Width="114" Visibility="Collapsed" TabIndex="250">
                                <!--<ComboBoxItem Content="More info..." />
                                <ComboBoxItem Content="Email" />
                                <ComboBoxItem Content="Email 2" />
                                <ComboBoxItem Content="Mobile" />
                                <ComboBoxItem Content="Telephone" />
                                <ComboBoxItem Content="Address 2" />
                                <ComboBoxItem Content="Nationality" />
                                <ComboBoxItem Content="Works at" />-->
                            </ComboBox>
                        </Grid>
                    <Grid Grid.Column="1" Name="grdDetailsStaticMapAndButtons" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="81*" />
                            <RowDefinition Height="95*" />
                        </Grid.RowDefinitions>
                        <Grid Margin="10,10,25,0" Name="grdImage" Background="LightGray" SizeChanged="grdImage_SizeChanged">
                            <Image Name="imgThumbnail" Stretch="Fill" SizeChanged="imgThumbnail_SizeChanged" />
                        </Grid>
                        <Button Content="Save" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="10,37,0,0" Name="btnSave" TabIndex="290" VerticalAlignment="Top" Width="75" Click="btnSave_Click" />
                        <Button Content="Add" Grid.Row="1" Height="23" HorizontalAlignment="Left" Margin="90,37,0,0" Name="btnAddFromDetails" TabIndex="300" VerticalAlignment="Top" Width="35" Click="btnAddFromDetails_Click" />
                        <Button Content="Close" Grid.Row="1" Height="23" HorizontalAlignment="Right" Margin="0,37,25,0" Name="btnCancel" TabIndex="310" VerticalAlignment="Top" Width="75" Click="btnCancel_Click" />
                        <Label Content="Not right? Be more specific in the address." FontSize="10" Foreground="#FF0000AF" Height="28" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Margin="10,4,25,0" Name="label1" VerticalAlignment="Top" Width="207" Grid.Row="1" />
                        <Label Content="" FontSize="10" FontStyle="Italic" Grid.Row="1" Height="28" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Margin="10,67,25,0" Name="lblSaved" VerticalAlignment="Top" Width="207" />
                        <Button Background="#00000000" Content="+" Height="23" HorizontalAlignment="Right" Margin="222,68,0,108" Name="btnPlusDetails" TabIndex="320" VerticalAlignment="Center" Width="20" Click="btnPlusDetails_Click" />
                        <Button Background="#00000000" Content="-" Height="23" HorizontalAlignment="Right" Margin="222,108,0,70" Name="btnMinusDetails" TabIndex="330" VerticalAlignment="Center" Width="20" Click="btnMinusDetails_Click" />
                    </Grid>
                </Grid>
                </ScrollViewer>
            </Grid>
        <!--</ScrollViewer>-->
    </TabItem>

Here's the window element:

<Window x:Class="mapperWPF.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        
    Title="Mapper" Height="600" Width="1000" Loaded="Window_Loaded" Initialized="Window_Initialized" Closing="Window_Closing" Name="wdoMain">
4
At full size with particular tab active it hangs but at sizes less then full no problems? - paparazzo
same kind of question as Blam : what happens if you change size (not maximise but just a resize). Hangs also ? - GameAlchemist
Exactly, re-sizing works great. It's only when it's actually maximized. - J-DawG
This should not break it but do you mean <RowDefinition Height="326*" /><RowDefinition Height="174" /> One * and the other not - paparazzo
That <Window /> looks OK. Render goes thru two cycles one where it calculates a layout and a second where it draws. It is like the second loop got a conflict. I have one WPF page where a click on an button cause info above to expand to where the button moves and then the click event happens a second time on another button that is now under the mouse. But when I try and break it down to a simple reproduction it works. I know not much help. My guess is those two passes are in conflict that cannot get resolved. Play with your layout. - paparazzo

4 Answers

2
votes

hang might come from infinite loops within your bindings / events handler / ... might also come from wpf not being able to solve all the constraints you set (width/maxWidth/... with bindings... ) to get all things displayed. So for the xaml : layout, sizes and visual stuff : make all things very simple, then put back your true design until it breaks. For the code : split it into some big blocks, and use booleans that allows to disable/enable those blocks. Then set to false/true those booleans until it runs fine. Then split the non-working code into smaller parts and enable/disable features until it runs fine, to find the loop. (booleans might prevent an event from firing, return default value at the start of a function, ... depends on what you're doing)

Just simple question, if you do a (some) pause(s) with the debugger, where does it stop ? might also get you to the core loop issue. If the debugger never stops in the code, it is likely that you have a xaml issue (layout).

1
votes

Its probably wise to break down your code a bit as over 3000 lines isn't going to help. Also if you have a lot of controls on your main window it is wise to look into threading and the way that WPF does UI threading http://msdn.microsoft.com/en-us/library/ms741870.aspx As the rendering of controls in WPF especially DataGrid's is slow. When I last used the WPF datagrid to display a large amount of data I implemented paging of the data and then loaded the first page while still retrieving the data to help speed things up.

Hope this helps

0
votes

WPF uses the resources of your graphic chip to render the application, notably when resizing the window. Have you tried running your application on a different hardware? Do you still get the same behaviour?

Also, it might come from some custom code in your maximise event handler.

0
votes

This is just plain strange. Please verify the symptoms. Please define "maximize". Is it only when you hit the maximize button? If in resize mode can you drag to the full size?

Please post the Window portion of the XAML.

From what I can tell there is no specific maximize event - it is just a type of resize.

According to this this link there might be different processing on a maximized over sized to maximum. "The order of precedence can also determine the size of a window when it is maximized" enter link description here It is a reach but you might have some setting in the Window XAML that is causing a conflict.