当WPF应用程序最大化时,UI通常会挂起

时间:2012-05-30 13:52:17

标签: c# wpf c#-4.0

我有一个WPF应用程序,当主窗口最大化并且特定选项卡可见并且在我的选项卡控件中位于顶部时,它经常挂起(变得完全没有响应)。当窗户恢复下来时,它就像魅力一样。我该怎么做才能解决这个问题?

有问题的标签有很多控件(文本框,图像,按钮,组合框栅格分割器,文本块,数据网格),我正在点亮这些不同字段的事件,因此这是一个非常“繁忙”的网格。 / p>

听起来类似于以下未解决的问题: 当窗口最大化(http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/4641d825-cf80-4b76-a4f9-14183bb72bb2#58dc7fdf-b43c-4782-833f-1d90401f1914

时,WPF Datagrids会冻结

让我总结说我没有设计我应该拥有的应用程序,并且在主窗口中有超过3000行代码。我可能应该创建这些繁忙的表单作为用户控件。这会导致我的问题吗?

   <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>

这是窗口元素:

<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 个答案:

答案 0 :(得分:2)

hang可能来自你的绑定/事件处理程序中的无限循环/ ...也可能来自wpf无法解决你设置的所有约束(width / maxWidth / ... with bindings ...)来获取显示所有内容。 所以对于xaml:布局,大小和视觉材料:使所有事情变得非常简单,然后将真正的设计放回去,直到它破裂。 对于代码:将其拆分为一些大块,并使用允许禁用/启用这些块的布尔值。然后设置为false / true那些布尔值,直到它运行正常。然后将非工作代码拆分为更小的部分并启用/禁用功能,直到它运行正常,找到循环。 (布尔值可能会阻止事件触发,在函数开始时返回默认值,...取决于你正在做什么)

简单的问题,如果您使用调试器进行(某些)暂停,它会在哪里停止?也可能会让你陷入核心循环问题。如果调试器永远不会在代码中停止,则可能是您遇到了xaml问题(布局)。

答案 1 :(得分:1)

分解你的代码可能是明智的,因为超过3000行不会有所帮助。此外,如果您的主窗口上有很多控件,那么查看线程和WPF进行UI线程的方式是明智的http://msdn.microsoft.com/en-us/library/ms741870.aspx 由于WPF中的控件呈现特别是DataGrid的速度很慢。当我上次使用WPF数据网格显示大量数据时,我实现了对数据的分页,然后加载第一页,同时仍然检索数据以帮助加快速度。

希望这有帮助

答案 2 :(得分:0)

WPF使用图形芯片的资源来渲染应用程序,特别是在调整窗口大小时。您是否尝试在不同的硬件上运行应用程序?你还有同样的行为吗?

此外,它可能来自最大化事件处理程序中的一些自定义代码。

答案 3 :(得分:0)

这很奇怪。请验证症状。请定义“最大化”。只有当你点击最大化按钮时?如果在调整大小模式下你可以拖动到完整大小?

请发布XAML的Window部分。

据我所知,没有特定的最大化事件 - 它只是一种调整大小。

根据这个链接,可能会有最大化超大到最大的不同处理。 “优先顺序也可以决定窗口最大化时的大小” enter link description here 这是一个范围,但您可能在Window XAML中有一些导致冲突的设置。