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

Silverlight Discussion :

autocompletion silverlight 4


Sujet :

Silverlight

  1. #1
    Membre confirmé
    Homme Profil pro
    Etudiant En dev jeux video ESGI. Dev c/c++
    Inscrit en
    Novembre 2012
    Messages
    63
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : Vietnam

    Informations professionnelles :
    Activité : Etudiant En dev jeux video ESGI. Dev c/c++

    Informations forums :
    Inscription : Novembre 2012
    Messages : 63
    Par défaut autocompletion silverlight 4
    Bonjour,

    J'ai un tres gros probleme.

    j'ai implementer une auto-competion de cette maniere.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    <toolkit:HeaderedContentControl Header="Localization" Style="{StaticResource LabeledField}">
                        <Controls:AutoComplete x:Name="LocalizationAutoComplete" 
                                             Height="20"
                                             IsFilter="True" 
                                             IsAutoAppend="True"
                                             CustomSource="{Binding Localizations}" 
                                             SelectedItem="{Binding Localization, Mode=TwoWay}"
                                             Text="{Binding Localization, Mode=TwoWay}" DropDownButtonVisibility="Collapsed"/>
                    </toolkit:HeaderedContentControl>
    il marche parfaitement. Mais j'ai de gros probleme pour faire un reset du champ(visuelle).
    si on tape quelque chose "nous meme au clavier" exexuter ce code ->
    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
     public void Reset()
            {
                this.Code = null;
                this.ShortName = null;
                this.LongName = null;
                this.Ticker = null;
                this.Currency = null;
                this.Issuer = null;
                this.InstrumentGroup = null;
                this.Family = null;
                this.Localization = null;
                this.QuotingType = null;
                this.IsActiveInstrument = true;
    
            }
    cela marche mais si on clique sur un des éléments qui apparait sur la liste deroulente. J'ai l'impression que le bind se casse .... en effet Localization est bien null mais!!! sur l'interface graphique on voit pas la box se vider .... Je comprend pas je me tire les cheveux!!!!

    Ha oui de part la construction du code il est impossible de faire un LocalizationAutoCompletion.Text = " ";
    parce que LocalizationAutoCompletion est hors de porte ....

    je vous met la déclaration de Localization a qui est la variable Binder au control ...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
     private string localization;
            public string Localization
            {
                get { return localization; }
                set
                {
                    localization = value;
                    NotifyOfPropertyChange(() => Localization);
                }
            }

  2. #2
    Membre confirmé
    Homme Profil pro
    Etudiant En dev jeux video ESGI. Dev c/c++
    Inscrit en
    Novembre 2012
    Messages
    63
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : Vietnam

    Informations professionnelles :
    Activité : Etudiant En dev jeux video ESGI. Dev c/c++

    Informations forums :
    Inscription : Novembre 2012
    Messages : 63
    Par défaut
    J'ai tout essayé .... meme cela RaisePropertyChangedEventImmediately mais rhaaaaa help me!!!!
    les recherches google ..... ne me donne rien de concluant

  3. #3
    Membre émérite Avatar de worm83
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Février 2010
    Messages
    459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2010
    Messages : 459
    Par défaut
    Je crois que tout simplement ta référence attaché à ton DataContext n'a pas été rafraichie, du coup ton DataContext pointe sur l'ancienne référence, enfin c'est souvent ce qui m'arrive quand j'ai ce genre de symptômes. (Quand je dit DataContext c'est de manière générale, la référence pointée par le binding n'est plus celle que tu utilise réellement en gros).

  4. #4
    Membre confirmé
    Homme Profil pro
    Etudiant En dev jeux video ESGI. Dev c/c++
    Inscrit en
    Novembre 2012
    Messages
    63
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : Vietnam

    Informations professionnelles :
    Activité : Etudiant En dev jeux video ESGI. Dev c/c++

    Informations forums :
    Inscription : Novembre 2012
    Messages : 63
    Par défaut
    Escuse moi ... Je suis débutant en silverlight (et surtout en c#).... mais Datacontext n'est pas seulement spécifique à WPF?

    tu vois j'ai une classe ou j'ai cela
    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
     public partial class AdvancedInstrumentsSearchView : System.Windows.Controls.UserControl {
    internal Syncfusion.Windows.Tools.Controls.AutoComplete LocalizationAutoComplete;
    private bool _contentLoaded;
            
            /// <summary>
            /// InitializeComponent
            /// </summary>
            [System.Diagnostics.DebuggerNonUserCodeAttribute()]
            public void InitializeComponent() {
                if (_contentLoaded) {
                    return;
                }
    _contentLoaded = true;
                System.Windows.Application.LoadComponent(this, new System.Uri("/**********.Dashboard.Silverlight.Instruments;component/Views/AdvancedIns" +
                            "trumentsSearchView.xaml", System.UriKind.Relative));
    this.LocalizationAutoComplete = ((Syncfusion.Windows.Tools.Controls.AutoComplete)(this.FindName("LocalizationAutoComplete")));

  5. #5
    Membre émérite Avatar de worm83
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Février 2010
    Messages
    459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2010
    Messages : 459
    Par défaut
    Alors premièrement Non, DataContext n'est pas spécifique a wpf.
    Quand je dit DataContext c'est un peu un terme "généric".
    Il me manque des éléments de ton code pour te dire où précisément il y a erreur (notamment ton modèle).
    Ce que je pense c'est que quand tu fait ton Reset, le binding n'est pas rafraichit et conserve l'ancienne référence tout simplement, et cela est certainement lié a ton DataContext ou ton ViewModel (qui est sensiblement la même chose si tu fait du MVVM)

  6. #6
    Membre confirmé
    Homme Profil pro
    Etudiant En dev jeux video ESGI. Dev c/c++
    Inscrit en
    Novembre 2012
    Messages
    63
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : Vietnam

    Informations professionnelles :
    Activité : Etudiant En dev jeux video ESGI. Dev c/c++

    Informations forums :
    Inscription : Novembre 2012
    Messages : 63
    Par défaut
    malheureusement, je ne peux pas te passer tout le code ...
    A quel moment on doit rafraichir le binding?
    J'avais l’idée de faire une variable static mais modifier l'architecture? non, je fais du MVVM.

  7. #7
    Membre émérite Avatar de worm83
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Février 2010
    Messages
    459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2010
    Messages : 459
    Par défaut
    Le binding se rafraichit tout seul.

    Dans ton Reset() essaye de mettre this.Localisation = "" (pour voir), si cela fonctionne c'est que c'est bien un problème de référence.

    (l'idée de la variable static n'est pas une bonne idée).

  8. #8
    Membre émérite Avatar de worm83
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Février 2010
    Messages
    459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2010
    Messages : 459
    Par défaut
    un autre truc quand tu fait ton reset(), est ce que derrière tu créer une nouvelle instance de la classe qui contient Localisation ?? Si tel est le cas tu doit la ré-attacher a ta vue car la nouvelle référence ne l'est pas.

  9. #9
    Membre confirmé
    Homme Profil pro
    Etudiant En dev jeux video ESGI. Dev c/c++
    Inscrit en
    Novembre 2012
    Messages
    63
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : Vietnam

    Informations professionnelles :
    Activité : Etudiant En dev jeux video ESGI. Dev c/c++

    Informations forums :
    Inscription : Novembre 2012
    Messages : 63
    Par défaut
    j'ai deja essaye le this.localization = " "; et LocalizationAutocomplete.Text = " ";

    mais cela ne marcher pas ...

  10. #10
    Membre émérite Avatar de worm83
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Février 2010
    Messages
    459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2010
    Messages : 459
    Par défaut
    Ok je crois que je viens de comprendre ce qui se passe, alors premierement tu doit avoir un ViewModel qui ressemble a ca (c'est un exemple)

    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
     
    public class MonObjetModel
    {
     
    string _Family;
     
    public string Family
    {
       get{ return _Family;}
       set
       { 
              _Family = value; 
              RaisedPropertyChanged(()=>Family);
            }
    }
    string _Localization;
     
    public string Localisation
    {
       get{return _Localisation;}
       set
       {
           _Localisation = value;
           RaisedPropertyChanged(()=> Localiation);
         }
    }
    .... (ect)       
    }
    Ensuite avant d'utiliser ton control tu va initialiser ta localisation, ou alors tu peux le faire dans le constructeur du control, mais normalement c'est pas trop sa place.

    Et ton control vas ressembler à ca :

    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
     
     
    public partial class monControl : Controls
    {
     
       public monControl()
       {
           InitializeComponent();
        }
     
       public MonObjetModel ViewModel
      {
        get { return DataContext as MonObjetModel;}
        set { DataContext=value;}
      }
    }

    Essaye d'utiliser cette méthode, je pense que tu n'aura plus de problème au niveau du binding

  11. #11
    Membre confirmé
    Homme Profil pro
    Etudiant En dev jeux video ESGI. Dev c/c++
    Inscrit en
    Novembre 2012
    Messages
    63
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : Vietnam

    Informations professionnelles :
    Activité : Etudiant En dev jeux video ESGI. Dev c/c++

    Informations forums :
    Inscription : Novembre 2012
    Messages : 63
    Par défaut
    Merci de ta reponce mais je ne comprend pas ... que veut tu dire par initialiser?

    je comprennd pas .. que signifie ce code ...

    public MonObjetModel ViewModel
    {
    get { return DataContext as MonObjetModel;}
    set { DataContext=value;}
    }

    Je doit l'appeler a quel moment? Je peut te contacter en MP?

  12. #12
    Membre émérite Avatar de worm83
    Homme Profil pro
    Architecte logiciel
    Inscrit en
    Février 2010
    Messages
    459
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Architecte logiciel
    Secteur : Conseil

    Informations forums :
    Inscription : Février 2010
    Messages : 459
    Par défaut
    Cette ligne permet de lier ton DataContext a ton model, tu affecte cette propriété et du coup ton datacontext est automatiquement rafraichit. Du coup tout les controls de la page hérite du datacontext.

    A un moment donné tu va créer une nouvelle instance de ton control soit dans du code behind -> MonControl = new Control() { ViewModel = inbstanceMonModel};

    Apres cette propriété peut être liée a une DependencyProperty (snipet propdp) auquel cas ton Xaml tu aura une ligne du genre :
    <monControl ViewModel="{Binding leTrucQuiVaBien}">

    Je t'invite très fortement à lire de la documentation dessus tu y verra beaucoup plus claire et cela facilitera ton développement.
    http://www.codeproject.com/Articles/...Context-in-WPF

    Cette ligne de ton code : System.Windows.Application.LoadComponent(this, new System.Uri("/**********.Dashboard.Silverlight.Instruments;component/Views/AdvancedIns" +"trumentsSearchView.xaml", System.UriKind.Relative));
    initialise ta localisation (c'est ce que je sous-entend par initialiser).

  13. #13
    Membre confirmé
    Homme Profil pro
    Etudiant En dev jeux video ESGI. Dev c/c++
    Inscrit en
    Novembre 2012
    Messages
    63
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : Vietnam

    Informations professionnelles :
    Activité : Etudiant En dev jeux video ESGI. Dev c/c++

    Informations forums :
    Inscription : Novembre 2012
    Messages : 63
    Par défaut
    Merci de ta réponse mais je suis complètement perdu.

    je dispose d'un XALM de ce type:
    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
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
     
    <UserControl x:Class="Rates.Dashboard.Silverlight.Instruments.Views.AdvancedInstrumentsSearchView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
        xmlns:Controls="clr-namespace:Syncfusion.Windows.Tools.Controls;assembly=Syncfusion.Tools.Silverlight" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:common="clr-namespace:Hsbc.Edfx.Dashboard.Framework.Interactivity;assembly=Hsbc.Edfx.Dashboard.Framework" mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="990" Loaded="UserControl_Loaded">
     
        <UserControl.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="/Rates.Dashboard.Silverlight.Instruments;component/Assets/Themes/Default/Theme.xaml" />
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </UserControl.Resources>
     
     
        <Grid  Margin="0,0,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="500"  />
                <ColumnDefinition Width="490*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
     
            <toolkit:HeaderedContentControl  Header="Advanced Search - Instruments" Style="{StaticResource HeaderedPanel}" Grid.Row="1" 
                            Grid.Column="0"  
                            HorizontalContentAlignment="Stretch" 
                            VerticalContentAlignment="Stretch">
                <toolkit:HeaderedContentControl.HeaderTemplate>
                    <DataTemplate/>
                </toolkit:HeaderedContentControl.HeaderTemplate>
                <StackPanel Orientation="Vertical">
     
                    <toolkit:HeaderedContentControl Header="Code" Style="{StaticResource LabeledField}">
                        <TextBox x:Name="Code">
                            <i:Interaction.Behaviors>
                                <common:AcceptCancelBehavior AcceptButton="{Binding ElementName=SearchAllInstruments}"  />
                            </i:Interaction.Behaviors>
                        </TextBox>
                    </toolkit:HeaderedContentControl>
     
                    <toolkit:HeaderedContentControl Header="ShortName" Style="{StaticResource LabeledField}">
                        <TextBox x:Name="ShortName" >
                            <i:Interaction.Behaviors>
                                <common:AcceptCancelBehavior AcceptButton="{Binding ElementName=SearchAllInstruments}"  />
                            </i:Interaction.Behaviors>
                        </TextBox>
                    </toolkit:HeaderedContentControl>
     
                    <toolkit:HeaderedContentControl Header="LongName" Style="{StaticResource LabeledField}">
                        <TextBox x:Name="LongName" >
                            <i:Interaction.Behaviors>
                                <common:AcceptCancelBehavior AcceptButton="{Binding ElementName=SearchAllInstruments}"  />
                            </i:Interaction.Behaviors>
                        </TextBox>
                    </toolkit:HeaderedContentControl>
     
                    <toolkit:HeaderedContentControl Header="Ticker" Style="{StaticResource LabeledField}">
                        <TextBox x:Name="Ticker" >
                            <i:Interaction.Behaviors>
                                <common:AcceptCancelBehavior AcceptButton="{Binding ElementName=SearchAllInstruments}"  />
                            </i:Interaction.Behaviors>
                        </TextBox>
                    </toolkit:HeaderedContentControl>
     
                    <toolkit:HeaderedContentControl Header="Family" Style="{StaticResource LabeledField}">
                        <Controls:AutoComplete x:Name="FamilyAutoComplete" 
                                             Height="20"
                                             IsFilter="True" 
                                             IsAutoAppend="True"
                                             CustomSource="{Binding InstrumentFamilies}" 
                                             SelectedItem="{Binding Family, Mode=TwoWay}"
                                             Text="{Binding Family, Mode=TwoWay}" DropDownButtonVisibility="Collapsed"/>
                    </toolkit:HeaderedContentControl>
     
                    <toolkit:HeaderedContentControl Header="Currency" Style="{StaticResource LabeledField}">
                        <ComboBox x:Name="Currencies" 
                            SelectedItem="{Binding Currency,Mode=TwoWay,ValidatesOnDataErrors=True}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                       <TextBlock Text="{Binding}" />
                                    </StackPanel>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </toolkit:HeaderedContentControl>
     
                    <toolkit:HeaderedContentControl Header="Issuer" Style="{StaticResource LabeledField}">
                        <StackPanel Orientation="Vertical">
                            <ComboBox x:Name="Issuers" 
                                      SelectedItem="{Binding Issuer,Mode=TwoWay}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal" ToolTipService.ToolTip="{Binding Description}">
                                                <TextBlock Text="{Binding}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </StackPanel>
                    </toolkit:HeaderedContentControl>
     
                    <toolkit:HeaderedContentControl Header="Group" Style="{StaticResource LabeledField}">
                        <StackPanel Orientation="Vertical">
                            <ComboBox x:Name="Groups" 
                                      SelectedItem="{Binding InstrumentGroup,Mode=TwoWay}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </StackPanel>
                    </toolkit:HeaderedContentControl>
     
     
                    <toolkit:HeaderedContentControl Header="Localization" Style="{StaticResource LabeledField}">
                        <Controls:AutoComplete x:Name="LocalizationAutoComplete" 
                                             Height="20"
                                             IsFilter="True" 
                                             IsAutoAppend="False"
                                             CustomSource="{Binding Localizations}" 
                                             SelectedItem="{Binding Localization, Mode= TwoWay}"
                                             Text="{Binding Localization, Mode= TwoWay}" DropDownButtonVisibility="Collapsed"/>
                    </toolkit:HeaderedContentControl>
     
     
     
                    <toolkit:HeaderedContentControl Header="Quoting Type" Style="{StaticResource LabeledField}">
                        <StackPanel Orientation="Vertical">
                            <ComboBox x:Name="QuotingTypes" 
                                      SelectedItem="{Binding QuotingType,Mode=TwoWay}">
                                <ComboBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding}" />
                                        </StackPanel>
                                    </DataTemplate>
                                </ComboBox.ItemTemplate>
                            </ComboBox>
                        </StackPanel>
                    </toolkit:HeaderedContentControl>
     
     
     
                    <toolkit:HeaderedContentControl Header="Active" Style="{StaticResource LabeledField}"></toolkit:HeaderedContentControl>
     
                </StackPanel>
            </toolkit:HeaderedContentControl>
     
     
     
     
            <Border Margin="2,0,0,0" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center">
                <StackPanel Orientation="Horizontal">
                    <Button x:Name="SearchAllInstruments" Margin="0,0,10,0" ToolTipService.ToolTip="Search all instruments">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="../Assets/Images/icon_search.png" Width="16" Height="16" />
                            <TextBlock Margin="5">Search</TextBlock>
                        </StackPanel>
                    </Button>
                    <!--<Button x:Name="SearchDebts" Margin="0,0,5,0"  ToolTipService.ToolTip="Search all debts with the supplied criteria (instrument's criterias AND debt's criteria">Search Debts</Button>-->
                    <Button x:Name="Reset" Margin="0,0,10,0" ToolTipService.ToolTip="Clear input fields in all panels">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="../Assets/Images/clear_icon.png" Width="16" Height="16" />
                            <TextBlock Margin="5">Reset</TextBlock>
                        </StackPanel>
                    </Button>
                </StackPanel>
            </Border>
            <CheckBox x:Name="IsActiveInstrument" Margin="115,270,6,9" Grid.Row="1" />
        </Grid>
     
     
    </UserControl>
    et une classe

    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
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
     
    using System;
    using Caliburn.Micro;
    using Dashboard.Framework.AutoMapper;
    using Rates.Dashboard.Instruments.Messages;
    using Rates.Dashboard.Instruments.Messages.DTO;
    using Rates.Dashboard.Silverlight.Instruments.Events;
    using Rates.Dashboard.Silverlight.Instruments.Views;
     
    namespace Rates.Dashboard.Silverlight.Instruments.ViewModels
    {
        public class AdvancedInstrumentsSearchViewModel : BaseViewModel
        {
            public IObservableCollection<IssuerSummary> Issuers { get; private set; }
            public IObservableCollection<InstrumentGroupSummary> Groups { get; private set; }
            public IObservableCollection<CurrencySummary> Currencies { get; private set; }
            public IObservableCollection<InstrumentQuotingTypeSummary> QuotingTypes { get; private set; }
            public IObservableCollection<LocalizationSummary> Localizations { get; private set; }
            public IObservableCollection<InstrumentFamilySummary> InstrumentFamilies { get; private set; }
     
     
            public AdvancedInstrumentsSearchViewModel()
            {
                this.Issuers = new BindableCollection<IssuerSummary>();
                this.Groups = new BindableCollection<InstrumentGroupSummary>();
                this.Currencies = new BindableCollection<CurrencySummary>();
                this.QuotingTypes = new BindableCollection<InstrumentQuotingTypeSummary>();
                this.Localizations = new BindableCollection<LocalizationSummary>();
                this.InstrumentFamilies = new BindableCollection<InstrumentFamilySummary>();
                this.IsActiveInstrument = true;
                LoadAdvancedInstrumentsSearchViewData();
            }
     
            private void LoadAdvancedInstrumentsSearchViewData()
            {
                this.IsBusy = true;
     
                var requestDispatcher = this.AsyncRequestDispatcherFactory.CreateAsyncRequestDispatcher();
     
                requestDispatcher.Add(new EditDebtViewDataRequest());
     
                requestDispatcher.ProcessRequests(responses =>
                {
                    var viewDataResponse = responses.Get<EditDebtViewDataResponse>();
                    Execute.OnUIThread(() =>
                    {
                        this.LoadViewData(viewDataResponse.EditDebtViewData);
                        this.IsBusy = false;
                    });
                },
                (exceptionInfo, exceptionType) =>
                {
                    Execute.OnUIThread(() =>
                    {
                        this.IsBusy = false;
                        this.WindowManager.ShowDialog(exceptionInfo.Message);
                    });
                });
            }
     
            public void LoadViewData(EditInstrumentViewData viewData)
            {
                if (viewData == null)
                    return;
     
                this.Issuers.Clear();
                this.Issuers.AddRange(viewData.Issuers);
                this.Issuers.Insert(0,new IssuerSummary() { Id= -1});
                this.Issuer = this.Issuers[0];
     
                this.Groups.Clear();
                this.Groups.AddRange(viewData.Groups);
                this.Groups.Insert(0, new InstrumentGroupSummary() { Id = -1 });
                this.InstrumentGroup = this.Groups[0];
     
                this.Currencies.Clear();
                this.Currencies.AddRange(viewData.Currencies);
                this.Currencies.Insert(0, new CurrencySummary() { Id = -1 });
                this.Currency = this.Currencies[0];
     
                this.QuotingTypes.Clear();
                this.QuotingTypes.AddRange(viewData.QuotingTypes);
                this.QuotingTypes.Insert(0, new InstrumentQuotingTypeSummary() { Id = -1 });
                this.QuotingType = this.QuotingTypes[0];
     
     
                this.Localizations.Clear();
                this.Localizations.AddRange(viewData.Localizations);
                this.Localization = null;
     
                this.InstrumentFamilies.Clear();
                this.InstrumentFamilies.AddRange(viewData.InstrumentFamilies);
                this.Family = null;
            }
     
            private string code;
            public string Code
            {
                get { return code; }
                set
                {
                    code = value;
                    NotifyOfPropertyChange(() => Code);
                }
            }
     
            private string shortName;
            public string ShortName
            {
                get { return shortName; }
                set
                {
                    shortName = value;
                    NotifyOfPropertyChange(() => ShortName);
                }
            }
     
            private string longName;
            public string LongName
            {
                get { return longName; }
                set
                {
                    longName = value;
                    NotifyOfPropertyChange(() => LongName);
                }
            }
     
            private string ticker;
            public string Ticker
            {
                get { return ticker; }
                set
                {
                    ticker = value;
                    NotifyOfPropertyChange(() => Ticker);
                }
            }
     
     
            private CurrencySummary currency;
            public CurrencySummary Currency
            {
                get { return currency; }
                set
                {
                    currency = value;
                    NotifyOfPropertyChange(() => Currency);
                }
            }
     
            private IssuerSummary issuer;
            public IssuerSummary Issuer
            {
                get { return issuer; }
                set
                {
                    issuer = value;
                    NotifyOfPropertyChange(() => Issuer);
                }
            }
     
            private InstrumentGroupSummary instrumentGroup;
            public InstrumentGroupSummary InstrumentGroup
            {
                get { return instrumentGroup; }
                set
                {
                    instrumentGroup = value;
                    NotifyOfPropertyChange(() => InstrumentGroup);
                }
            }
     
            private string family;
            public string Family
            {
                get { return family; }
                set
                {
                    family = value;
                    NotifyOfPropertyChange(() => Family);
                }
            }
     
            private string localization;
            public string Localization
            {
                get { return localization; }
                set
                {
                    localization = value;
                    NotifyOfPropertyChange(() => Localization);
                    //RaisePropertyChangedEventImmediately(() => Localization);
                    //PropertyChanged(this, new PropertyChangedEventArgs(localization)); 
                    //PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(localization));
                    Refresh();
                }
            }
     
            private InstrumentQuotingTypeSummary quotingType;
            public InstrumentQuotingTypeSummary QuotingType
            {
                get { return quotingType; }
                set
                {
                    quotingType = value;
                    NotifyOfPropertyChange(() => QuotingType);
                }
            }
     
            private bool? isActiveInstrument;
            public bool? IsActiveInstrument
            {
                get { return isActiveInstrument; }
                set
                {
                    isActiveInstrument = value;
                    NotifyOfPropertyChange(() => IsActiveInstrument);
                }
            }
     
            public void SearchAllInstruments()
            {
                var instrumentCriteria = this.MapTo<InstrumentCriteria>();
                this.EventAggregator.Publish(new SearchInstrumentsEvent { InstrumentCriteria = instrumentCriteria });
            }
           /* public event PropertyChanged 
            private void OnPropertyChanged(string property)
            {
                if (public event PropertyChanged != null)
                {
                    PropertyChanged(this,new PropertyChangedEventArgs(property));
                }
            }*/
     
     
            public void Reset()
            {
                this.Code = null;
                this.ShortName = null;
                this.LongName = null;
                this.Ticker = null;
                this.Currency = null;
                this.Issuer = null;
                this.InstrumentGroup = null;
                this.Family = null;
                this.Localization = null;
                this.localization = " ";
                NotifyOfPropertyChange(() => Localization);
                this.QuotingType = null;
                this.IsActiveInstrument = true;
     
                LoadAdvancedInstrumentsSearchViewData();
                //AdvancedInstrumentsSearchView temp = new AdvancedInstrumentsSearchView();
                //temp.RAZ_VIEW(this);
                //temp.VM = temp.
                this.Localizations.Clear();
     
                this.Localization = null;
            }
     
            public void BackToBasicSearch()
            {
     
            }
        }
    }

  14. #14
    Membre confirmé
    Homme Profil pro
    Etudiant En dev jeux video ESGI. Dev c/c++
    Inscrit en
    Novembre 2012
    Messages
    63
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : Vietnam

    Informations professionnelles :
    Activité : Etudiant En dev jeux video ESGI. Dev c/c++

    Informations forums :
    Inscription : Novembre 2012
    Messages : 63
    Par défaut
    Je ne comprend pas!!!

    Tout les autre control se met a jour facilement NotifyOfPropertyChange(() => toto);

    met les controls de type autocomplete ...
    Pourtant je vois bien la variable se mettre à jour. j'ai l'impression que le bind se casse au moment ou on clique sur un des items presente dans la liste émergente.
    donc meme si la property est correctement mise à jour. cela n'affiche pas la valeur attendu dans le control ....

    code cs associe au xalm
    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
     
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Rates.Dashboard.Silverlight.Instruments.ViewModels;
     
    namespace Rates.Dashboard.Silverlight.Instruments.Views
    {
        public partial class AdvancedInstrumentsSearchView : UserControl
        {
            object se;
            RoutedEventArgs ed;
            public AdvancedInstrumentsSearchView()
            {
                InitializeComponent(); 
     
            }
     
            public void UserControl_Loaded(object sender, RoutedEventArgs e)
            {
                this.LocalizationAutoComplete.Text = " - Any -";
                var Selected = this.LocalizationAutoComplete.SelectedItem;
                se = sender;
                ed = e;
            }
     
            public void RAZ_VIEW(AdvancedInstrumentsSearchViewModel ob)
            {
                System.Windows.Application.LoadComponent(this, new System.Uri("/Rates.Dashboard.Silverlight.Instruments;component/Views/AdvancedIns" +
                            "trumentsSearchView.xaml", System.UriKind.Relative));
                this.LocalizationAutoComplete = ((Syncfusion.Windows.Tools.Controls.AutoComplete)(this.FindName("LocalizationAutoComplete")));
                this.LocalizationAutoComplete.Text = "RAZ";
                var Selected = this.LocalizationAutoComplete.SelectedItem;
                this.LocalizationAutoComplete.SelectedItem = ob.Localization;
                ob.Refresh();
                //UserControl_Loaded(se,ed);
            }
     
            private void Reset_Click(object sender, RoutedEventArgs e)
            {
                LocalizationAutoComplete.Text = "RAZ";
                LocalizationAutoComplete = ((Syncfusion.Windows.Tools.Controls.AutoComplete)(this.FindName("LocalizationAutoComplete")));
            }
     
            public SearchInstrumentsViewModel VM
            {
                get { return DataContext as SearchInstrumentsViewModel; }
                set { DataContext = value; }
            }
        }
    }

  15. #15
    Membre éclairé
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2006
    Messages
    436
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2006
    Messages : 436
    Par défaut
    Essaye de surcharger ta méthode Equals de ton objet : exemple

    if obj != null return Localization.Id = (obj as Localization).ID
    else base.Equals(obj)

    un truc du genre.

    Pour compléter le code fournit précédemment, comme tu ne bind pas le DataContext de ton UC sur la property ViewModel, fais comme ceci :


    public partial class monControl : Controls
    {

    public monControl()
    {
    InitializeComponent();
    MonObjetModel = New ObjetModel()
    ou
    DataContext = New ObjetModel()
    }

    public MonObjetModel ViewModel
    {
    get { return DataContext as MonObjetModel;}
    set { DataContext=value;}
    }
    }

Discussions similaires

  1. [3.2M4] Petits freezes lors de l'autocomplete
    Par Glob dans le forum Eclipse Java
    Réponses: 3
    Dernier message: 28/12/2005, 11h41
  2. AutoComplete un peu spécial
    Par kobe dans le forum Composants VCL
    Réponses: 7
    Dernier message: 21/07/2005, 11h08
  3. Autocompletion de mot dans un trichedit
    Par mteirek_m dans le forum Composants VCL
    Réponses: 3
    Dernier message: 01/06/2005, 20h22
  4. [kdevelop] autocompletion
    Par hiko-seijuro dans le forum Environnement de Développement Intégré (EDI)
    Réponses: 2
    Dernier message: 13/11/2004, 13h57
  5. [Dbgrid] Picklist & Autocomplete ?
    Par dudux dans le forum Bases de données
    Réponses: 7
    Dernier message: 11/07/2004, 10h32

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