0

我有“MainWindow”,我在其中创建了名为“Maket”的新窗口,关闭后它们不会从内存中释放。因此,我从 ANTS 内存分析器发布了一张树的图片,如果需要代码,我可以发布它。有什么问题,为什么他们没有被释放?

在此处输入图像描述

TreeAndGrids.xaml

<UserControl x:Class="ССПИ.Интерфейс.TreeAndGrids"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:DataBase="clr-namespace:ССПИ.DataBase"
         xmlns:OpenSourceControls1="clr-namespace:OpenSourceControls;assembly=DockPanelSplitter"
         xmlns:Helpers="clr-namespace:ССПИ.Helpers"
         xmlns:Интерфейс="clr-namespace:ССПИ.Интерфейс"
         xmlns:Controls="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
         xmlns:Primitives="clr-namespace:Microsoft.Windows.Controls.Primitives;assembly=WPFToolkit"
         xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
         xmlns:chrome="clr-namespace:Xceed.Wpf.Toolkit.Chromes;assembly=WPFToolkit.Extended"
         xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters;assembly=WPFToolkit.Extended" mc:Ignorable="d" d:DesignHeight="379" d:DesignWidth="600" Loaded="UserControl_Loaded_1">
<UserControl.Resources>
    <Style x:Key="SeparatorStyle"
       TargetType="{x:Type Border}">
        <Setter Property="BorderThickness" Value="1,0,0,0"/>
        <Setter Property="BorderBrush" Value="#FFC5C5C5"/>
        <Setter Property="Margin" Value="10,0,10,0"/>
        <Setter Property="Width" Value="2"/>
        <Setter Property="Background" Value="White"/>
    </Style>


    <conv:InverseBoolConverter x:Key="InverseBoolConverter" />

    <LinearGradientBrush x:Key="PopupDarkBorderBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFA3AEB9" Offset="0" />
        <GradientStop Color="#FF8399A9" Offset="0.375" />
        <GradientStop Color="#FF718597" Offset="0.375" />
        <GradientStop Color="#FF617584" Offset="1" />
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="PopupBackgroundBrush" StartPoint="0,0" EndPoint="0,1">
        <LinearGradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Offset="0" Color="#FFffffff" />
                <GradientStop Offset="1" Color="#FFE8EBED" />
            </GradientStopCollection>
        </LinearGradientBrush.GradientStops>
    </LinearGradientBrush>

    <Style x:Key="DropDownButtonStyle"
         TargetType="{x:Type xctk:DropDownButton}">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource NuclearButtonFocusVisual}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Foreground" Value="{DynamicResource OutsideFontColor}" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type xctk:DropDownButton}">
                    <Grid x:Name="MainGrid">
                        <ToggleButton x:Name="PART_DropDownButton"
                            Grid.Column="1" 
                            IsChecked="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                            IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}">

                            <ToggleButton.Template>
                                <ControlTemplate TargetType="ToggleButton">
                                    <ContentPresenter />
                                </ControlTemplate>
                            </ToggleButton.Template>
                            <Grid>
                                <chrome:ButtonChrome VerticalAlignment="Stretch" VerticalContentAlignment="Center" x:Name="ToggleButtonChrome"
                                         CornerRadius="2.75"
                                         RenderChecked="{TemplateBinding IsOpen}"
                                         RenderEnabled="{TemplateBinding IsEnabled}"
                                                    RenderMouseOver="{Binding IsMouseOver, ElementName=PART_DropDownButton}"
                                                    RenderPressed="{Binding IsPressed, ElementName=PART_DropDownButton}">
                                    <chrome:ButtonChrome.Style>
                                        <Style TargetType="{x:Type chrome:ButtonChrome}" BasedOn="{x:Null}">
                                            <Setter Property="Foreground" Value="{StaticResource ButtonFontColor}"/>
                                            <Setter Property="Padding" Value="3"/>
                                            <Setter Property="FocusVisualStyle" Value="{DynamicResource NuclearButtonFocusVisual}"/>
                                            <Setter Property="Template" Value="{DynamicResource ButtonChromeTemplate}" />
                                            <Setter Property="HorizontalContentAlignment" Value="Center" />
                                            <Setter Property="VerticalContentAlignment" Value="Center" />
                                        </Style>
                                    </chrome:ButtonChrome.Style>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <ContentPresenter Margin="{TemplateBinding Padding}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="true" />
                                        <Grid x:Name="arrowGlyph" IsHitTestVisible="False" Margin="4,3,4,3" Grid.Column="1">
                                            <Path Width="7" Height="4" Data="M 0,1 C0,1 0,0 0,0 0,0 3,0 3,0 3,0 3,1 3,1 3,1 4,1 4,1 4,1 4,0 4,0 4,0 7,0 7,0 7,0 7,1 7,1 7,1 6,1 6,1 6,1 6,2 6,2 6,2 5,2 5,2 5,2 5,3 5,3 5,3 4,3 4,3 4,3 4,4 4,4 4,4 3,4 3,4 3,4 3,3 3,3 3,3 2,3 2,3 2,3 2,2 2,2 2,2 1,2 1,2 1,2 1,1 1,1 1,1 0,1 0,1 z" Fill="#FF000000" />
                                        </Grid>
                                    </Grid>
                                </chrome:ButtonChrome>
                            </Grid>
                        </ToggleButton>

                        <Popup x:Name="PART_Popup" 
                     AllowsTransparency="True"
                     StaysOpen="False"
                     Focusable="False"
                     IsOpen="{Binding IsChecked, ElementName=PART_DropDownButton}">
                            <Border BorderThickness="1" Background="{StaticResource PopupBackgroundBrush}" BorderBrush="{StaticResource PopupDarkBorderBrush}">
                                <ContentPresenter Content="{TemplateBinding DropDownContent}" />
                            </Border>
                        </Popup>

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="Visibility" Value="Collapsed" />
    </Style>
    <Style x:Key="buttonsstyle" TargetType="{x:Type Control}">
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="Height" Value="36" />
        <Setter Property="Width" Value="90" />
    </Style>

    <Style TargetType="{x:Type chrome:ButtonChrome}" BasedOn="{x:Null}" x:Key="toggle">
        <Setter Property="Foreground" Value="{StaticResource ButtonFontColor}"/>
        <Setter Property="Padding" Value="3"/>
        <Setter Property="FocusVisualStyle" Value="{DynamicResource NuclearButtonFocusVisual}"/>
        <Setter Property="Template" Value="{DynamicResource ButtonChromeTemplate}" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
    </Style>

    <Helpers:ClientsConnectionsConverter x:Key="Converter"/>
    <Helpers:TreeConverter x:Key="treeConverter"/>
    <Helpers:ZeroToHiddenConverter x:Key="zeroToHiddenConverter"/>
    <Style x:Key="DataGridCellStyle" TargetType="{x:Type Controls:DataGridCell}">
        <Setter Property="BorderThickness" Value="0"/>
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Foreground" Value="Black"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</UserControl.Resources>

<DockPanel>
    <Grid DockPanel.Dock="Top">
        <DockPanel Height="Auto" Name="dockPanel2" LastChildFill="False"  Margin="0,0, 0,7">
            <Grid DockPanel.Dock="Left" Name="grid1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Button Margin="1" Grid.Column="1" Grid.Row="0"  Name="button1" Click="button1_Click"  HorizontalAlignment="Left" Height="36" Width="36" ToolTip="Предыдущие сутки">
                    <Button.Content>
                        <Image Source="/АСВПИ;component/images/previous.png" Stretch="None" />
                    </Button.Content>
                </Button>
                <Controls:DatePicker Grid.Column="0" Margin="10,0,0,0" CalendarOpened="datePicker1_CalendarOpened" FontSize="22" FontFamily="Tahoma"  Height="36" HorizontalAlignment="Center" Name="datePicker1" SelectedDateChanged="datePicker1_SelectedDateChanged" Width="150" ToolTip="Операционные сутки" VerticalContentAlignment="Center" FontWeight="Normal" />
                <Button Margin="1" Name="button2" Grid.Column="2" Grid.Row="0" Click="button2_Click"   HorizontalAlignment="Left" Height="36" Width="36" ToolTip="Следующие сутки">
                    <Button.Content>
                        <Image Source="/АСВПИ;component/images/next.png" Stretch="None" />
                    </Button.Content>
                </Button>
                <Border Grid.Column="3" Name="sep1" Style="{StaticResource SeparatorStyle}"/>
                <ComboBox Grid.Column="4" FontSize="22" Name="pl_lev_combo" VerticalContentAlignment="Center" Height="36" Width="160" HorizontalAlignment="Right" ToolTip="Уровень планирования" Margin="0,6,0,6">
                    <ComboBoxItem Content="ОУ" IsSelected="True"></ComboBoxItem>
                    <ComboBoxItem Content="X-1"></ComboBoxItem>
                    <ComboBoxItem Content="X-2"></ComboBoxItem>
                    <ComboBoxItem Content="ВСВГО"></ComboBoxItem>
                </ComboBox>
                <Grid Grid.Column="4" HorizontalAlignment="Stretch">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition  Name="seccolumn"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                <Label Name="compare_label" HorizontalAlignment="Left" Grid.Column="0"  Margin="10,12,83,12" Height="24" Visibility="Collapsed" FontSize="16" FontFamily="Tahoma" Width="89" Grid.ColumnSpan="2">Сравнить с</Label>
                <ComboBox Grid.Column="1"  Name="secondary_pl_lev" VerticalContentAlignment="Center" Height="17" FontSize="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Width="68" Margin="0,0,20,8">
                    <ComboBoxItem Content="" IsSelected="True"></ComboBoxItem>
                    <ComboBoxItem Content="ОУ"></ComboBoxItem>
                    <ComboBoxItem Content="X-1"></ComboBoxItem>
                    <ComboBoxItem Content="X-2"></ComboBoxItem>
                    <ComboBoxItem Content="ВСВГО"></ComboBoxItem>
                    <ComboBoxItem Content="Об.х. ОУ"></ComboBoxItem>
                    <ComboBoxItem Content="Об.х. Х-1"></ComboBoxItem>
                    <ComboBoxItem Content="Об.х. Х-2"></ComboBoxItem>
                    <ComboBoxItem Content="Об.х. ВСВГО"></ComboBoxItem>
                </ComboBox>
                </Grid>
            </Grid>
            <Border Name="sep2" Style="{StaticResource SeparatorStyle}"/>
            <chrome:ButtonChrome  Style="{StaticResource toggle}"  Height="48" Width="48" Name="button4" PreviewMouseDown="button4_Click">
                <chrome:ButtonChrome.Content>
                    <Image Source="/АСВПИ;component/images/check.png" Stretch="None"  />
                </chrome:ButtonChrome.Content>
            </chrome:ButtonChrome>


            <xctk:DropDownButton Height="48" Width="120" HorizontalContentAlignment="Right" Style="{StaticResource DropDownButtonStyle}"  Name="ou_send" Content="ОУ">
                <xctk:DropDownButton.DropDownContent>


                    <ListBox Name="ou_send_menu" ItemsSource="{Binding}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <MenuItem Header="{Binding Converter={StaticResource ResourceKey=Converter}, ConverterParameter=OUButtons}" ToolTip="{Binding Address}" Click="OUSendClick"/>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

                </xctk:DropDownButton.DropDownContent>
            </xctk:DropDownButton>

            <xctk:DropDownButton Name="rsv_vsvgo_send" HorizontalContentAlignment="Right" Style="{StaticResource DropDownButtonStyle}" Width="120" Height="48" Content="РСВ/ВСВГО">
                <xctk:DropDownButton.DropDownContent>
                    <ListBox Name="rsv_vsvgo_menu">
                        <ListBox.Items>
                            <MenuItem Header="Отправить Х-1" Name="x1send" Click="x1send_Click">
                            </MenuItem>
                            <MenuItem Header="Отправить Х-2" Name="x2send" Click="x2send_Click">
                            </MenuItem>
                            <MenuItem Header="Отправить ВСВГО" Name="vsvgosend" Click="vsvgosend_Click">
                            </MenuItem>
                        </ListBox.Items>
                    </ListBox>
                </xctk:DropDownButton.DropDownContent>
            </xctk:DropDownButton>
    <Grid DockPanel.Dock="Left" Name="Dock_Separate" MinWidth="150" MaxWidth="900" >
        <Grid.RowDefinitions>
            <RowDefinition Name="tree_h" Height="1*" MinHeight="200" ></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition MinHeight="150" Height="150"></RowDefinition>
        </Grid.RowDefinitions>
        <Slider
x:Name="treeScaleSlider" Visibility="Collapsed"
ToolTip="Determines the UI scale factor."
Value="1" Minimum="0.1" Maximum="4"/>
        <TreeView Grid.Row="0" HorizontalAlignment="Stretch" BorderBrush="LightGray" ItemsSource="{Binding}" Name="treeObjects" VerticalAlignment="Stretch" SelectedItemChanged="treeObjects_SelectedItemChanged" KeyDown="treeObjects_KeyDown" PreviewMouseRightButtonDown="OnPreviewMouseRightButtonDown" VerticalContentAlignment="Center">
            <TreeView.LayoutTransform>

                    <ScaleTransform 
        CenterX="0" CenterY="0"
        ScaleX="{Binding ElementName=treeScaleSlider,Path=Value}"
        ScaleY="{Binding ElementName=treeScaleSlider,Path=Value}"
    />

            </TreeView.LayoutTransform>
            <TreeView.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightGray"/>
                <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="LightGray"/>
                <HierarchicalDataTemplate DataType="{x:Type DataBase:Objects}" ItemsSource="{Binding SubObjects}">
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16" Height="16" Source="{Binding IconSource}"/>
                        <TextBlock Foreground="{Binding ColorInTree}"><TextBlock.Text><MultiBinding Converter="{StaticResource treeConverter}" ConverterParameter="NameAndId"><Binding Path="name" /><Binding Path="id" /></MultiBinding></TextBlock.Text></TextBlock>
                    </StackPanel>
                </HierarchicalDataTemplate>
            </TreeView.Resources>
            <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">

                    <Style.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected"
                                   Value="true"/>
                                <Condition Property="IsSelectionActive"
                                   Value="false"/>
                            </MultiTrigger.Conditions>
                            <Setter
                            Property="Background"
                            Value="LightGray"/>
                            <Setter Property="Foreground"
                            Value="Black"/>
                        </MultiTrigger>
                    </Style.Triggers>

                    <Setter Property="Foreground" Value="{Binding ColorInTree}"></Setter>
                </Style>
            </TreeView.ItemContainerStyle>
            <TreeView.ContextMenu>
                <ContextMenu ItemsSource="{Binding}" Visibility="{Binding Path=ContextMenuItems.Count,Converter={StaticResource zeroToHiddenConverter}}">
                </ContextMenu>
            </TreeView.ContextMenu>
        </TreeView>
        <GridSplitter ResizeDirection="Rows" HorizontalAlignment="Stretch" Grid.Row="1" Width="Auto"  Height="3"/>
        <Grid Grid.Row="2" >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Stretch" Margin="0,0,0,5" Visibility="Collapsed" Name="zvk_panel">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="30"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Image Grid.Column="0" Name="zvkImageStatus" HorizontalAlignment="Center" Margin="2" VerticalAlignment="Center" Source="/АСВПИ;component/images/waiting.png" ToolTip="Подключение к серверу 'Заявки'..."  Height="20" Width="20"></Image>
                <TextBlock Grid.Column="1" Name="zvk_label" HorizontalAlignment="Center"  VerticalAlignment="Stretch" TextWrapping="WrapWithOverflow" Text="Заявки" FontSize="14"></TextBlock>
                <TextBlock Grid.Column="1" HorizontalAlignment="Center" Name="zvk_result" VerticalAlignment="Stretch" TextWrapping="WrapWithOverflow" Visibility="Collapsed"  Text="Заявок нет"></TextBlock>
            </Grid>

            <Controls:DataGrid Grid.Row="1" Name="zvk_datagrid" AutoGenerateColumns="False" Visibility="Collapsed" VerticalAlignment="Stretch" BorderBrush="LightGray" Background="White" CanUserReorderColumns="False" GridLinesVisibility="Vertical" IsReadOnly="True" SelectionMode="Single" SelectionUnit="FullRow" SnapsToDevicePixels="True" VerticalGridLinesBrush="LightGray" VerticalContentAlignment="Center" PreviewMouseDown="zvk_datagrid_PreviewMouseDown">
                <Controls:DataGrid.Resources>
                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="LightGray"/>
                </Controls:DataGrid.Resources>
                <Controls:DataGrid.CellStyle>
                    <Style TargetType="Controls:DataGridCell">
                        <Setter Property="BorderThickness" Value="0"/>
                    </Style>
                </Controls:DataGrid.CellStyle>
                <Controls:DataGrid.Columns>
                    <Controls:DataGridTemplateColumn Header="Станция" Width="Auto" MinWidth="100" CellStyle="{StaticResource DataGridCellStyle}" SortMemberPath="station" CanUserSort="True">
                        <Controls:DataGridTemplateColumn.HeaderStyle>
                            <Style TargetType="Primitives:DataGridColumnHeader">
                                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                            </Style>
                        </Controls:DataGridTemplateColumn.HeaderStyle>
                        <Controls:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding station}"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </Controls:DataGridTemplateColumn.CellTemplate>
                    </Controls:DataGridTemplateColumn>


                    <Controls:DataGridTemplateColumn Header="ΔP" Width="Auto" MinWidth="30" CellStyle="{StaticResource DataGridCellStyle}" SortMemberPath="zvk.power_down" CanUserSort="True">
                        <Controls:DataGridTemplateColumn.HeaderStyle>
                            <Style TargetType="Primitives:DataGridColumnHeader">
                                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                            </Style>
                        </Controls:DataGridTemplateColumn.HeaderStyle>
                        <Controls:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding zvk.power_down}"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </Controls:DataGridTemplateColumn.CellTemplate>
                    </Controls:DataGridTemplateColumn>
                    <Controls:DataGridTemplateColumn Header="Дата" Width="Auto" MinWidth="90" CellStyle="{StaticResource DataGridCellStyle}" SortMemberPath="zvk.date_begin" CanUserSort="True">
                        <Controls:DataGridTemplateColumn.HeaderStyle>
                            <Style TargetType="Primitives:DataGridColumnHeader">
                                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                            </Style>
                        </Controls:DataGridTemplateColumn.HeaderStyle>
                        <Controls:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Text="{Binding zvk.date_begin, StringFormat={}{0:dd.MM.yyyy H:mm}}"></TextBlock>
                                    <TextBlock Text="{Binding zvk.date_end, StringFormat={}{0:dd.MM.yyyy H:mm}}"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </Controls:DataGridTemplateColumn.CellTemplate>
                    </Controls:DataGridTemplateColumn>
                </Controls:DataGrid.Columns>
            </Controls:DataGrid>
        </Grid>
    </Grid>
    <OpenSourceControls1:DockPanelSplitter x:Name="separator1" DockPanel.Dock="Left" Width="4" VerticalAlignment="Stretch"></OpenSourceControls1:DockPanelSplitter>
    <Grid DockPanel.Dock="Top" MinWidth="300">
        <Grid.RowDefinitions>
            <RowDefinition Height="1*" MinHeight="200"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition MinHeight="150" Height="150"></RowDefinition>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" Name="border"  BorderBrush="Gray" BorderThickness="0.5" Background="White" MinWidth="400">
            <Интерфейс:Grid x:Name="grid" MinWidth="300"></Интерфейс:Grid>
        </Border>
        <GridSplitter ResizeDirection="Rows" HorizontalAlignment="Stretch" Grid.Row="1" Width="Auto"  Height="3"/>
        <Grid Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition MinHeight="30" MaxHeight="30"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Label Grid.Row="0" HorizontalAlignment="Center" FontSize="14">Паспортные данные</Label>
            <Controls:DataGrid BorderBrush="LightGray"  Grid.Row="1" MinHeight="100" SelectionMode="Single" SelectionUnit="Cell" IsReadOnly="True" AutoGenerateColumns="False" EnableColumnVirtualization="true" EnableRowVirtualization="true" CanUserReorderColumns="False" CanUserResizeColumns="True" CanUserAddRows="false" CanUserResizeRows="False" CanUserSortColumns="False" Name="dataGridConst"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="White" VerticalGridLinesBrush="LightGray" HorizontalGridLinesBrush="LightGray">
                    <Controls:DataGrid.Resources>
                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="White"/>
                </Controls:DataGrid.Resources>
                <Controls:DataGrid.Columns>
                    <Controls:DataGridTemplateColumn Header="Наименование" Width="*">
                        <Controls:DataGridTemplateColumn.HeaderStyle>
                            <Style TargetType="Primitives:DataGridColumnHeader">
                                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                            </Style>
                        </Controls:DataGridTemplateColumn.HeaderStyle>
                        <Controls:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Foreground="Black" Text="{Binding name}"/>
                            </DataTemplate>
                        </Controls:DataGridTemplateColumn.CellTemplate>
                    </Controls:DataGridTemplateColumn>
                    <Controls:DataGridTemplateColumn Header="Значение" Width="*">
                        <Controls:DataGridTemplateColumn.HeaderStyle>
                            <Style TargetType="Primitives:DataGridColumnHeader">
                                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                            </Style>
                        </Controls:DataGridTemplateColumn.HeaderStyle>
                        <Controls:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock Foreground="Black" Text="{Binding value}"/>
                            </DataTemplate>
                        </Controls:DataGridTemplateColumn.CellTemplate>
                    </Controls:DataGridTemplateColumn>
                </Controls:DataGrid.Columns>

            </Controls:DataGrid>
        </Grid>
    </Grid>
</DockPanel>

4

1 回答 1

3

对于 WPF 应用程序,内存泄漏的原因有很多。可能是事件处理程序在关闭时没有被删除,绑定到非依赖属性,并且可以是其他任何东西。

访问此网站以获取示例案例,看看哪一个适合您的案例,因为您没有发布整个代码,包括您的应用程序背后的代码。

http://svetoslavsavov.blogspot.com/2010/05/memory-leaks-in-wpf-applications.html

于 2013-09-16T06:10:42.687 回答