IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Windows Presentation Foundation Discussion :

Message d'Exception : Dispatcher processing has been suspended ?


Sujet :

Windows Presentation Foundation

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 33
    Par défaut Message d'Exception : Dispatcher processing has been suspended ?
    Bonjour,

    Mon application me retourne l'exception suivante :
    Additional information: 'System.Windows.Data.BindingExpression' value cannot be assigned to property 'ItemsSource' of object 'System.Windows.Controls.ComboBox'. Dispatcher processing has been suspended, but messages are still being processed. Error at object 'System.Windows.Data.Binding' in markup file 'MetaDataManagerControl;component/metadatamanagerview.xaml'.
    Mon application possede 2 listbox. La premiere me permet de selectionner un element principal. La seconde, affiche la description associé à cet element dans plusieurs langues.
    Il existe egalement un bouton qui me permet d'ajouter une nouvelle description à mon element dans de nouvelles langues.

    Lorsque l'on clique sur ce bouton, j'ajoute un nouveau listboxitem a ma seconde listbox. Cet item contient une combobox que j'alimente avec le contenu d'un fichier Xml contenant les codes de langues à utiliser ( fr-FR, en-GB, en-US, etc).

    si je valide mes modifications, tout fonctionne parfaitement, ma base et bien mise a jour et mon interface fait ce quelle doit faire.
    Malheureusement, des que je reitere une seconde fois cette operation, j'ai cette exception.

    Cela semble lié au binding de la combobox.

    je met ci-dessous les codes associé a l'item template ainsi qu'au binding.

    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
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
     
     <XmlDataProvider x:Key="LanguagesProvider" Source="Languages.xml" XPath="/Languages"  />
            <CollectionViewSource x:Key="SortedLanguagesView" Source="{Binding Source={StaticResource LanguagesProvider}, XPath=Language}">
                <CollectionViewSource.SortDescriptions >
                    <cm:SortDescription PropertyName="@title" Direction="Ascending" />
                </CollectionViewSource.SortDescriptions>
            </CollectionViewSource>
     
    <DataTemplate x:Key="mEditableLocalizedDataTemplate">
     
                <Grid Background="Transparent" >
                    <Border BorderBrush="{StaticResource ML_GradientBrush}" BorderThickness="4" CornerRadius="10,10,10,10" Background="{StaticResource ML_DarkBlue}" Margin="5,5,5,5" >
     
                        <Grid Background="Transparent" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="25" />
                                <ColumnDefinition Width="30*" />
                                <ColumnDefinition Width="30*" />
                                <ColumnDefinition Width="30*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                            </Grid.RowDefinitions>
     
                            <TextBlock Grid.Column="1" Grid.Row="0" Margin="10,5,0,0" >Language</TextBlock>
                            <ComboBox Name="mComboLanguages"  SelectionChanged="mComboLanguages_SelectionChanged" Grid.Column="2" Grid.Row="0" Margin="5,5,10,5" Width="150"   ItemsSource="{Binding Source={StaticResource SortedLanguagesView}}"  >
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding XPath=@title}" />
                                            <TextBlock Text=" (" />
                                            <TextBlock Text="{Binding XPath=@code}" />
                                            <TextBlock Text=")" />
                                        </StackPanel>
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
     
                            <TextBlock  Margin="10,5,0,0" Grid.Column="1" Grid.Row="1">Property A</TextBlock>
                            <TextBox  Style="{StaticResource TextBoxStyle}"  Grid.Column="2" Grid.Row="1" Background="{DynamicResource ML_LightBlue}" Text="{Binding Path=PropertyA}" Margin="5,5,10,5" ></TextBox>
     
                            <TextBlock Margin="10,5,0,0" Grid.Column="1" Grid.Row="3" >Property B</TextBlock>
                            <TextBox Style="{StaticResource TextBoxStyle}" Grid.Column="2" Grid.Row="3" Text="{Binding Path=PropertyB}" Margin="5,5,10,5" ></TextBox>
     
                            <TextBlock Margin="10,5,0,0" Grid.Column="1" Grid.Row="2" >Property C</TextBlock>
                            <TextBox Style="{StaticResource TextBoxStyle}" Grid.Column="2"  Grid.Row="2" Text="{Binding Path=Property C}" Margin="5,5,10,5" AcceptsReturn="True" ></TextBox>
     
                            <StackPanel Grid.Row="4" Grid.Column="2"  Orientation="Horizontal"  HorizontalAlignment="Right" >
                                <Image Source="/MetaDataManagerControl;component/Resources/database_remove.ico" Height="15" ToolTip="Deny changes" Margin="0,0,0,10" Style="{StaticResource ML_ImageStyle}" MouseLeftButtonDown="onCancelNewLanguage" />
                                <Image Source="/MetaDataManagerControl;component/Resources/database_accept.ico" Height="15" ToolTip="Accept changes" Margin="40,0,40,10" Style="{StaticResource ML_ImageStyle}" MouseLeftButtonDown="onValidateNewLanguage" />
                            </StackPanel>
     
                        </Grid>
                    </Border>
                </Grid>
            </DataTemplate>
    Petite remarque en passant, dans la methode mComboLanguages_SelectionChanged, je recupere la valeur code de langue (ex: fr-FR) resultant de la selection de la combobox pour l'affecter à une propriété de l'objet correspondant a ce même listboxitem. N'y a t'il pas une meilleure methode ?

    Merci de vos conseils.

  2. #2
    Rédacteur
    Avatar de Thomas Lebrun
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    9 161
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France

    Informations forums :
    Inscription : Octobre 2002
    Messages : 9 161
    Par défaut
    Bizarre, le code de ton binding me semble correct

    Tu ne pourrais pas mettre ton projet en téléchargement, histoire qu'on y jette un oeil ?

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 33
    Par défaut
    Voila, j'ai posté le projet !

    Par contre sans la base de données, ca risque d'etre casse pieds ... Il faudra commenter les appels et faire des mocks ...

    Soyez clément avec l'etat du code et du projet, c'est ma premiere utilisation des WPF ^^'

    Sinon est ce que ca ne peut pas provenir de ce que je fais dans le code behind :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    private void mComboLanguages_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                EditableLocalizedVideoData data = mBoxData.SelectedItem as EditableLocalizedVideoData;
                if (data != null)
                {
                    if (e.AddedItems.Count > 0)
                    {
                        System.Xml.XmlElement elem = e.AddedItems[0] as System.Xml.XmlElement;
                        data.Language = elem.Attributes["code"].Value;
                    }
     
                    e.Handled = false;
                }
    }
    Fichiers attachés Fichiers attachés

  4. #4
    Membre averti
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    33
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 33
    Par défaut
    Je pense qu'a force de test, j'ai un soupcons de reponse !!


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
     <XmlDataProvider x:Key="LanguagesProvider" Source="Languages.xml" XPath="/Languages"  />
            <CollectionViewSource x:Key="SortedLanguagesView" Source="{Binding Source={StaticResource LanguagesProvider}, XPath=Language}">
                <CollectionViewSource.SortDescriptions >
                    <cm:SortDescription PropertyName="@title" Direction="Ascending" />
                </CollectionViewSource.SortDescriptions>
            </CollectionViewSource>
    Je possede un provider xml dont je tri le contenu avec mon element CollectionViewSource. Je fais mon binding ensuite sur cette vue triée ...

    Il semblerai que le responsable de cette exception soit la vue qui trie mes données !??? Si je bind directement le provider, je n'ai plus (ou beaucoup moins) ce probleme.

    Auriez-vous des conseils à ce sujet ?

Discussions similaires

  1. message d'erreur <The module has not been deployed>
    Par dev_2007 dans le forum Tomcat et TomEE
    Réponses: 0
    Dernier message: 10/11/2010, 21h49
  2. message d'erreur <The module has not been deployed>
    Par alamako dans le forum Logging
    Réponses: 4
    Dernier message: 08/09/2010, 09h02
  3. Réponses: 0
    Dernier message: 06/08/2010, 11h12
  4. Réponses: 1
    Dernier message: 02/04/2007, 15h33

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo