WPF - 2ème source de valeur
Bonjour
Je remplis ma fenêtre avec une liste de données, je mets les objets dans la liste puis quand terminé je fais DataContext :
Code:
Application.Current.Dispatcher.Invoke(new Action(() => this.DataContext = lstOperations));
Cependant dans ma boucle je fais également une somme d'une quantité que je souhaite afficher dans un label, contrairement à avant ce n'est qu'une somme de toutes les opérations., la valeur n'est plus dans la liste.
Code:
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
| <Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.03*" />
<RowDefinition Height="0.04*" />
<RowDefinition Height="0.04*" />
<RowDefinition Height="0.88*"/>
<RowDefinition Height="0.02*" />
</Grid.RowDefinitions>
<Label Grid.Row="1" />
<Button Name="btnParamsAffichage" HorizontalAlignment="Left" Width="100" Grid.Row="1" Background="#b2c9ef" Click="btnParamsAffichage_Click" />
<Label Grid.Row="2" />
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="3" >
<ItemsControl x:Name="lvDataBinding" HorizontalContentAlignment="Stretch" BorderThickness="0" Margin="10" Grid.Row="3" Background="{x:Null}" ItemsSource="{Binding}" Foreground="White">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:CL_Operation}">
<Border BorderBrush="White" BorderThickness="1" CornerRadius="3" Margin="0,3" Grid.ColumnSpan="0" Background="Transparent" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid Width="{Binding strWidth}" Height="60" Background="Transparent" Margin="0,1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.06*" />
<ColumnDefinition Width="0.09*" />
<ColumnDefinition Width="0.1*" />
<ColumnDefinition Width="0.12*" />
<ColumnDefinition Width="0.1*" />
<ColumnDefinition Width="0.1*" />
<ColumnDefinition Width="0.1*" />
<ColumnDefinition Width="0.05*" />
<ColumnDefinition Width="0.05*" />
<ColumnDefinition Width="0.05*" />
<ColumnDefinition Width="0.05*" />
<ColumnDefinition Width="0.03*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<UniformGrid Tag="{Binding strRueck}" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" MouseLeftButtonUp="Test" >
<UniformGrid.Style>
<Style TargetType="{x:Type UniformGrid}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="White"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="false">
<Setter Property="Background" Value="{Binding scbBackColor}"/>
</Trigger>
</Style.Triggers>
</Style>
</UniformGrid.Style>
<TextBlock Text="{Binding strPriorite}" FontSize="36" Foreground="Red" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold"/>
</UniformGrid>
<UniformGrid Grid.Column="0" Grid.Row="2" Background="{Binding scbBackColor}" MouseLeftButtonUp="Test" >
<TextBlock Text="{Binding strSsSect}" FontSize="14" Foreground="Black" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontWeight="Bold" />
</UniformGrid>
<UniformGrid Grid.Column="1" Grid.Row="0" Grid.RowSpan="3">
<TextBlock Text="{Binding strRetardAvanceText}" FontSize="28" Foreground="{Binding scbColorRetardAvance}" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" />
</UniformGrid>
<UniformGrid Grid.Column="2" Grid.Row="0" Grid.ColumnSpan="2" Grid.RowSpan="2">
<UniformGrid.Style>
<Style TargetType="{x:Type UniformGrid}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="Background" Value="Gray"/>
</Trigger>
</Style.Triggers>
</Style>
</UniformGrid.Style>
<TextBlock Tag="{Binding strRueck}" Foreground="{Binding scbColorNumOfOp}" Text="{Binding strNoOfOp}" FontSize="26" FontWeight="Bold" MouseLeftButtonUp="Test"/>
</UniformGrid>
<UniformGrid Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="3">
<TextBlock Text="{Binding strDescriptionOp}" FontSize="14" Foreground="White"/>
</UniformGrid>
<UniformGrid Grid.Column="4" Grid.Row="0">
<TextBlock Text="{Binding strNoArticle}" FontSize="14" Foreground="White"/>
</UniformGrid>
<UniformGrid Grid.Column="4" Grid.Row="1">
<TextBlock Text="{Binding strDateFormatee}" FontSize="14" Foreground="White"/>
</UniformGrid>
<UniformGrid Grid.Column="5" Grid.Row="0">
<TextBlock Text="{Binding strPcesPoste}" FontSize="14" Foreground="White"/>
</UniformGrid>
<UniformGrid Grid.Column="5" Grid.Row="1">
<TextBlock Text="{Binding strTpsPoste}" FontSize="14" Foreground="White"/>
</UniformGrid>
<UniformGrid Grid.Column="6" Grid.Row="0">
<TextBlock Text="{Binding strTempsPoste}" FontSize="14" Foreground="White"/>
</UniformGrid>
<UniformGrid Grid.Column="6" Grid.Row="1">
<TextBlock Text="{Binding strClient}" FontSize="14" Foreground="White"/>
</UniformGrid>
<UniformGrid Grid.Column="5" Grid.Row="2" Grid.ColumnSpan="3">
<TextBlock Text="{Binding strTypeOp}" FontSize="14" Foreground="White"/>
</UniformGrid>
<UniformGrid Grid.Column="9" Grid.Row="3">
<TextBlock Text="{Binding strAuart}" FontSize="12" Foreground="White" FontWeight="Bold"/>
</UniformGrid>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="2"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>
<Label HorizontalAlignment="Right" Foreground="White" Grid.Row="4" Content="{Binding Path=strTotaux}"></Label>
<Label HorizontalAlignment="Center" Foreground="White" Grid.Row="4" Content=""></Label>
</Grid> |
C'est l'avant dernière ligne avec le Binding strTotaux
J'aimerais remplir une variable strTotaux, qui n'a plus rien à avoir avec ma liste et afficher son contenu
Dans mon cas j'ai des données qui s'affichent si je fais une variable strTotaux dans ma classe mais du coup il ne m'affiche que la valeur de strTotaux de la classe du 1er enregistrement de la liste donc rien n'est encore additionné.
Comment procéder ? merci