Bonjour à tous,

J'ai un petit souci de destruction d'objet :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
<Grid Name="gridMain">
                <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                        <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <TextBlock x:Name="lblRessource" Text="Ressources :" TextWrapping="Wrap" Grid.Row="1" Foreground="{StaticResource Black}" Margin="10,10,0,0" HorizontalAlignment="Left"/>
                <ComboBox x:Name="cbxGroupeRessource" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Margin="10,0,10,3" Style="{StaticResource ComboBoxStyleWhite}" VerticalAlignment="Center" Grid.Row="2"/>
                <ComboBox x:Name="cbxTypeRessource" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Margin="10,0,10,3" Style="{StaticResource ComboBoxStyleWhite}" VerticalAlignment="Center" Grid.Row="3"/>
                <ListBox x:Name="listRessource" Grid.Row="4" ItemsSource="{Binding Mode=OneWay}" BorderBrush="{StaticResource Border}" Style="{StaticResource ListBoxStyleDispo}" HorizontalContentAlignment="Stretch" ItemContainerStyle="{StaticResource ListBoxItemStyle1}" Margin="10,0,10,10">
                </ListBox>
                <StackPanel x:Name="stackPanel" HorizontalAlignment="Right" Grid.Row="5" Margin="10" Orientation="Horizontal" MaxHeight="150">
                        <Button x:Name="btnAnnuler" Content="Annuler" Margin="0,0,5,0" HorizontalAlignment="Center" Style="{StaticResource BtnGreyAnnuler}" VerticalAlignment="Center" Cursor="Hand" Width="80"/>
                        <Button x:Name="btnValider" Content="Valider" HorizontalAlignment="Center" Style="{StaticResource BtnGreyValider}" VerticalAlignment="Center" Cursor="Hand" Width="80"/>
                </StackPanel>
                <Border Margin="8,0" VerticalAlignment="Top" Grid.Row="5" BorderBrush="#FF9E9E9E" BorderThickness="0,2,0,0"/>
                <Border Margin="8,0" VerticalAlignment="Top" Grid.Row="5" BorderBrush="White" BorderThickness="0,1,0,0"/>
        </Grid>
 
  public void Dispose()
        {
            _baseVue = null;
            this.Resources.Clear();
 
            listRessource.DataContext = null;
            listRessource.ItemContainerStyle = null;
            listRessource.ItemsSource = null;
            listRessource.Style = null;
            listRessource.BorderBrush = null;
 
            listRessource.Template = null;
            listRessource.ItemTemplate = null;
            listRessource.ItemsPanel = null;
 
            stackPanel.Children.Clear();
            gridMain.Children.Clear();
            gridMain.ColumnDefinitions.Clear();
            gridMain.RowDefinitions.Clear();
 
            listRessource = null;
            gridMain = null;
        }
Dans ce cas là mon user control se détruit correctement (j'ai un point d'arrêt dans le destructeur et je passe dedans sans problème).

Par contre, si j'ajoute un datatemplate a ma listRessource comme ceci :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
                <ListBox x:Name="listRessource" Grid.Row="4" ItemsSource="{Binding Mode=OneWay}" BorderBrush="{StaticResource Border}" Style="{StaticResource ListBoxStyleDispo}" HorizontalContentAlignment="Stretch" ItemContainerStyle="{StaticResource ListBoxItemStyle1}" Margin="10,0,10,10">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <CheckBox Content="{Binding Mode=OneWay}" IsEnabled="{Binding IsEnabled, Mode=TwoWay}" IsChecked="{Binding IsChecked, Mode=TwoWay}" Style="{StaticResource CKGreyRessource}" HorizontalContentAlignment="Stretch"/>
                </DataTemplate>
            </ListBox.ItemTemplate>
                </ListBox>
 
listRessource.ItemTemplate = null;
Mon objet ne se détruit plus du tout.

Quelqu'un a une idée sur le problème ??