Bonjour
J'ai un web service basé sur OData qui me renvoie des produits.
1 2
|
var context = new ServiceReference1.OPhelieEntities(new Uri("http://localhost:62848/WcfDataService1.svc")); |
Je recupert ma CollectionViewSource et crée ma DataServiceCollection defnit la fonction deCallBack
1 2 3 4 5 6
|
System.Windows.Data.CollectionViewSource myCollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["pRODUITSViewSource"];
var customerBindingCollection = new DataServiceCollection<PRODUITS>();
customerBindingCollection.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(customerBindingCollection_LoadCompleted); |
A stade on lancer le chargement Asych
1 2
|
customerBindingCollection.LoadAsync(query); |
Ça ne marche pas avec le binding suivant
<TextBox Grid.Column="1" Grid.Row="0" Height="23" HorizontalAlignment="Left" Margin="3" Name="referenceTextBox1" Text="{Binding Path=reference, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" VerticalAlignment="Center" Width="120" />
Je comprend pourquoi:
on fait le binding sur le CustommerBindingCollection qui est une Collection de produit alors que mon textbox à besoin d'un produit.
Donc actuellement je fait
1 2 3 4 5 6 7
| void customerBindingCollection_LoadCompleted(object sender, LoadCompletedEventArgs e)
{
label1.Content = (temp.Subtract(DateTime.Now)).Seconds+"/" + (temp.Subtract(DateTime.Now)).Milliseconds;
foreach (PRODUITS p in (IEnumerable) sender)
toto.DataContext = p;
} |
qui ne me plait pas (faire un enum sur un collection qui a un seul resultat
Avez vous de meilleur practice?
Cordialement
MARQUIS VINcent
Partager