3 pièce(s) jointe(s)
Probleme de scrolling avec la Datagrid de WPFToolKit
Bonjour j'ai une Datagrid avec une colone que j'ai templater qui represente une checkbox. Jusqu'ici tout va bien.
Parcontre en execustion lorsque je coche admetton les 5 premiere rangée et que je scroll pour aller plus bas je me rend compte qu'il y en a d'autre de sélectionner. Ce n'est pas moi qui les a sélectionner. Tous cela c'est produit lorsque j'ai scroller pour aller voir d'autre enregistrement.
Voici des copie d'écran démontrant mon probleme ( assez space lol )
1. Datagrid_prise_1.JPG : Je rentre dans ma fenetre je sélectionne les 5 premier
2. Datagrid_prise_2.JPG : Je scroll vers le bas tous de suite apres avoir coché mes 5 enregistrement
3. Datagrid_prise_3.JPG Je reviens dans le haut de ma grille avec la scroll bar et la sélection initiale a changé.
A mon avis c'est un probleme dans le xaml. Car j'ai commenter tous le code behind qui etais en rapport avec cette sélection et le problème persiste toujours.
Je vais paster mon xaml(Les ligne interessante sont en bold) de mon user control si vous pourriez avoir une idée pour résoudre mon problème ce serais sympas.
Merci Beaucoup.
Pascal Wick
Programmeur-Analyste Sr.
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
|
<UserControl x:Class="JMB.FRAMEWORK.WPF.UserControls.JMBSearchControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:jmb="clr-namespace:JMB.Framework.WPF;assembly=JMB.Framework.WPF"
xmlns:jmbGrid="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"
xmlns:local="clr-namespace:JMB.FRAMEWORK.WPF.UserControls"
Height="544" Width="422" Name="ctl" Style="{DynamicResource JMBSearchControlStyle}" >
<UserControl.Resources>
<ControlTemplate x:Key="grdMultiSelectTemplateAutoGenerateColumns" TargetType="{x:Type jmbGrid:DataGrid}">
<jmbGrid:DataGrid AutoGenerateColumns="True"
ItemsSource="{Binding Path=Datasource.DefaultView, ElementName=ctl}"
SelectionChanged="DataGrid_SelectionChanged">
<jmbGrid:DataGrid.Columns>
<jmbGrid:DataGridTemplateColumn Width="60">
<jmbGrid:DataGridTemplateColumn.Header>
<TextBlock HorizontalAlignment="Center">Sélection</TextBlock>
</jmbGrid:DataGridTemplateColumn.Header>
<jmbGrid:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox x:Name="chkCol" Checked="chkCol_Checked" Unchecked="chkCol_Unchecked"></CheckBox>
</DataTemplate>
</jmbGrid:DataGridTemplateColumn.CellTemplate>
</jmbGrid:DataGridTemplateColumn>
</jmbGrid:DataGrid.Columns>
</jmbGrid:DataGrid>
</ControlTemplate> <ControlTemplate x:Key="grdSingleSelectTemplateAutoGenerateColumns" TargetType="{x:Type jmbGrid:DataGrid}">
<jmbGrid:DataGrid AutoGenerateColumns="True" ItemsSource="{Binding Path=Datasource.DefaultView, ElementName=ctl}">
</jmbGrid:DataGrid>
</ControlTemplate>
<Style x:Key="JMBSearchControlStyle" TargetType="{x:Type UserControl}">
<Style.Triggers>
<Trigger Property="local:JMBSearchControl.DisplayDataAtOpening" Value="True">
<Setter Property="local:JMBSearchControl.VResultVisibility" Value="Visible"/>
</Trigger>
<Trigger Property="local:JMBSearchControl.DisplayDataAtOpening" Value="False">
<Setter Property="local:JMBSearchControl.VResultVisibility" Value="Collapsed"/>
</Trigger>
<Trigger Property="local:JMBSearchControl.MultiSelect" Value="True">
<Setter Property="local:JMBSearchControl.GridTemplate" Value="{StaticResource grdMultiSelectTemplateAutoGenerateColumns}"/>
</Trigger>
<Trigger Property="local:JMBSearchControl.MultiSelect" Value="False">
<Setter Property="local:JMBSearchControl.GridTemplate" Value="{StaticResource grdSingleSelectTemplateAutoGenerateColumns}"/>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<!--Definition du controle-->
<Grid Width="379" Height="507" Name="_grdMain">
<StackPanel Orientation="Vertical">
<jmb:View jmb:ViewItem.LabelPadding="3"
jmb:ViewItem.LabelPosition="Left"
Name="vSearch" Height="161"
MinHeight="32.35" MinWidth="365"
Width="371"
Margin="3.2,10,14.5,0"
VerticalAlignment="Top"
jmb:ViewItem.ContentPadding="2"
>
<jmb:View.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"></StackPanel>
</ItemsPanelTemplate>
</jmb:View.ItemsPanel>
<TextBox Name="txtSearch1" TextChanged="txtSearch1_TextChanged" Height="25" Width="290" jmb:ViewItem.LabelContent="Critère1"/>
<TextBox Name="txtSearch2" Height="25" Width="290" jmb:ViewItem.LabelContent="Critère1"/>
<TextBox Name="txtSearch3" Height="25" Width="290" jmb:ViewItem.LabelContent="Critère1"/>
<TextBox Name="txtSearch4" Height="25" Width="290" jmb:ViewItem.LabelContent="Critère1" Visibility="{Binding Path=VResultVisibility, ElementName=ctl}"/>
<Button Click="btnSearch_Click" Name="btnSearch" Width="25" Height="25" IsEnabled="False"></Button>
</jmb:View>
<jmb:View Margin="0,5"
Name="vResult"
Height="323" Width="369" Visibility="{Binding Path=VResultVisibility, ElementName=ctl}">
<jmbGrid:DataGrid
Name="grdResult"
Width="369" Height="327" MinHeight="327" MinWidth="369"
Template="{Binding Path=GridTemplate, ElementName=ctl}"
>
</jmbGrid:DataGrid>
</jmb:View>
</StackPanel>
</Grid>
</UserControl> |
Meme probleme avec DataGridCheckBoxColumn
J'ai exactement le meme probleme en utilisant la DataGridCheckBoxColumn. Le probleme etant que je coche un certains nombre d'enregistrement, je scroll vers le bas je découvre d'autre item de coché alors qu'il ne faut pas et quand je reviens en haut avec le scroll je me rend compte que ce n'est pas du tout la sélection initiale. Et ce autant pour une column templater de type checkbox.
J'ai extrais mon datagrid de mon usercontrol et je l'ai creer directement dans une window.
Voici le code xaml. Les ligne interressante sont en bold
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<Window x:Class="WpfApplication1.TestPascal.WindowSearch"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:myControl="clr-namespace:JMB.FRAMEWORK.WPF.UserControls;assembly=JMB.FRAMEWORK.WPF.UserControls"
xmlns:jmbGrid="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"
Title="WindowSearch" Height="593" Name="ctl" Width="458" Loaded="Window_Loaded">
<Grid Width="432">
<jmbGrid:DataGrid AutoGenerateColumns="True"
ItemsSource="{Binding Path=Datasource.DefaultView, ElementName=ctl}"
SelectionChanged="grd_SelectionChanged"
Name="grd"
>
<jmbGrid:DataGrid.Columns>
<jmbGrid:DataGridCheckBoxColumn x:Name="Selection2" Header="Selection2"></jmbGrid:DataGridCheckBoxColumn>
</jmbGrid:DataGrid.Columns>
</jmbGrid:DataGrid>
</Grid>
</Window> |
Pour voir la problématique : voir copie d'ecran de mon premier message dans cette conversation.
Je n'ai plus d'idée.