XAML itemscontrol visibility

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-03-18T00:07:20Z Indexed on 2010/03/18 0:11 UTC
Read the original article Hit count: 579

Filed under:

Hello,

I have a ItemsControl in my XAML code. When some trigger occur i want to collapse the full itemsControl, so all the elements.

                        <ItemsControl Name="VideoViewControl"  ItemsSource="{Binding Videos}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapPanel ItemHeight="120" ItemWidth="160" Name="wrapPanel1"/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <views:VideoInMenuView />
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>

The trigger:

     <DataTrigger Value="videos" Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}, AncestorLevel=1}, Path=DataContext.VideosEnable}">
                    <Setter Property="ScrollViewer.Visibility" Value="Visible" TargetName="test1" />
                    <Setter Property="ScrollViewer.Visibility" Value="Collapsed" TargetName="test2" />
<Setter Property="WrapPanel.Visibility" Value="Collapsed" TargetName="wrapPanel1" />
                </DataTrigger>

When I add the last setter the program crashes. Without this last setter it works fine but no visibility change....

What is wrong with this code? What is the write method to collapse all the elements of a ItemsControl with a trigger?

© Stack Overflow or respective owner

Related posts about xaml