views:

10

answers:

1

I am rotating an image inside datagrid using animations based on DataTrigger value. It works fine when vertical scrollbar is not visible, but when records are more and vertical scrollbar is displayed and I scrolls up and down other images also starts rotating, which should rotate bcoz there values doesn't matches with condition. Below is the code

<toolkit:DataGrid x:Name="_grid" SelectionUnit="FullRow" AutoGenerateColumns="False">
                        <toolkit:DataGrid.GroupStyle>
                            <GroupStyle>
                                <GroupStyle.Panel>
                                    <ItemsPanelTemplate>
                                        <toolkit:DataGridRowsPresenter/>
                                    </ItemsPanelTemplate>
                                </GroupStyle.Panel>
                                <GroupStyle.HeaderTemplate>
                                    <DataTemplate>
                                        <StackPanel>
                                            <TextBlock Text="{Binding Path=Name}" FontWeight="Bold" Padding="3"/>
                                        </StackPanel>
                                    </DataTemplate>
                                </GroupStyle.HeaderTemplate>
                                <GroupStyle.ContainerStyle>
                                    <Style TargetType="{x:Type GroupItem}">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="{x:Type GroupItem}">
                                                    <Expander IsExpanded="True" BorderBrush="#FFA4B97F" BorderThickness="0,0,0,1" >
                                                        <Expander.Header>
                                                            <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Background="AliceBlue">
                                                                <TextBlock Text="Model : "/>
                                                                <TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
                                                                <TextBlock Text="Count : " Margin="5,0,0,0"/>
                                                                <TextBlock FontWeight="Bold" Text="{Binding Path=ItemCount}"/>                   
                                                            </StackPanel>
                                                        </Expander.Header>
                                                        <ItemsPresenter />
                                                    </Expander>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </GroupStyle.ContainerStyle>
                            </GroupStyle>
                        </toolkit:DataGrid.GroupStyle>
                        <toolkit:DataGrid.Columns>
                            <toolkit:DataGridTemplateColumn>
                                <toolkit:DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Grid Width="23" Height="23">
                                            <Image x:Name="StatusImg" Height="16" Width="16" ToolTip="{Binding Message}">
                                                <Image.LayoutTransform>
                                                    <RotateTransform x:Name="rotate" Angle="0"/>
                                                </Image.LayoutTransform>
                                            </Image>
                                        </Grid>
                                        <DataTemplate.Triggers>
                                            <DataTrigger Binding="{Binding Status}">
                                                <DataTrigger.Value>
                                                    <DeviceDiscovery:DeviceStatusCategory>Communicating</DeviceDiscovery:DeviceStatusCategory>
                                                </DataTrigger.Value>
                                                                                                   <Setter TargetName="StatusImg" Property="Source" Value="../Resources/Images/communicating_small.png" />
                                                                                                <DataTrigger.EnterActions>
                                                    <BeginStoryboard>
                                                        <Storyboard>
                                                            <DoubleAnimation From="0"
                                                                             To="360"
                                                                             Duration="00:00:03"
                                                                             RepeatBehavior="Forever"
                                                                             Storyboard.TargetName="rotate"
                                                                             Storyboard.TargetProperty="Angle"/>
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </DataTrigger.EnterActions>
                                                <DataTrigger.ExitActions>
                                                    <BeginStoryboard>
                                                        <Storyboard>
                                                            <DoubleAnimation To="0"
                                                                             Duration="00:00:00"
                                                                             Storyboard.TargetName="rotate"
                                                                             Storyboard.TargetProperty="Angle"/>
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </DataTrigger.ExitActions>
                                            </DataTrigger>
                                        </DataTemplate.Triggers>
                                    </DataTemplate>
                                </toolkit:DataGridTemplateColumn.CellTemplate>
                            </toolkit:DataGridTemplateColumn>
                        <toolkit:DataGridTextColumn Header="IP" Width="Auto" Binding="{Binding IP}"></toolkit:DataGridTextColumn>

A: 

My problem is solved, Please refer to below link for solution

Disabling WPF DataGrid Virtualization

VishalBhatt