Hi
I currently have all my cards defaulted to collapsed.
If the user goes in and manually expands a few cards through out the list.
I like to have a way to callapse them all and vice versa.
If the user has a bunch of cards expanded. I like to beable to expand all the rest of the cards.
Is there a easy and simple way of doing this ? I like to hook this up to two buttons.
Thanks
Allen
Hello Allen,
The easiest way to do this is to set the XamDataCards' ViewSettings.ShouldCollapseCards to true or false. However, please note that this will not take in to account any changes in the settings that the user may have made to explicitly set a panel to be collapsed or expanded.
If you want to override what the user has set and make sure all cards are expanded or collapsed at the same time then you'll need to set the collapsed state on all the individual cards to the default. To do this, iterate through all the records and set the Record.IsContainingCardCollapsed property to null.
Please let me know if you have any further questions or concerns about this matter.
Does this approach work for you? Please let me know if you have any further questions or concerns about this matter.
Yes, this worked for me.
I loop through each card and set it manually
Thank You
Incidentally, when you use this means, the cards do not "know" they've been collapsed.
For example: expand Card 1, hit a "Collapse All" button that iterates through the cards and sets IsContainingCardCollapsed = true, then try to manually re-expand Card 1.
Card 1 still "thinks" it's expanded, so presumably the first click tries to toggle the card to its collapsed state - which it already is - and it takes a second click to expand it.
QUESTION: Is there a way to collapse a card (or all cards) via code, such that the very next click of the expand button will expand it?
Bumping this issue -- any responses to my prior question?? This is still an issue for us...
Hello,
I was unable to reproduce the behavior you're describing. When i set the Record.IsContainingCardCollapsed property to true, the CollapseCardButton of the Card corresponding to this record get toggled. So the first time you click it, the card expands. Could you give us some more info on styles and any other related pieces of code from your application which have anything to do with expanding and collapsing the cards?
Ivan
Infragistics
Software Engineer in Test
So, in looking at the source, it seems that we need to set IsContainingCardCollapsed to null when it should pick up the value that was set in ShouldCollapseCards, and to the true/false value otherwise.
Thus if we start with ShouldCollapseCards=True
CollapseAll ==> Set IsContainingCardCollapsed to null
ExpandAll ==> Set IsContainingCardCollapsed to false
Otherwise if we start with ShouldCollapseCards=False
CollapseAll ==> Set IsContainingCardCollapsed to true
ExpandAll ==> Set IsContainingCardCollapsed to null
This is a bit confusing, but seems to work properly. I noticed the original response to this issue mentioned setting the value to null (rather than to true/false), so I'm curious if this is in fact how we should be implementing this??
One other thing... if I turn OFF the ShouldCollapseCards property, I get the same problem the opposite way. Hit Collapse All, then Expand All. At that point, trying to collapse a card takes two clicks.
Hi Ivan - sorry to have left this hanging, but it's bubbled back up in priority for us now. I've done further investigation on this, and it appears to be a consequence of having the CardViewSettings property of ShouldCollapseCards="True". Without this setting everything seems to behave properly, but when it's set, things seem to get out of sync. I have an example project I can send to you if it's helpful, but I've pasted the relevant source below:
MainWindow.xaml
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:igDP="http://infragistics.com/DataPresenter" x:Class="CardViewExpandCollapseIssue.MainWindow" x:Name="Window" Title="MainWindow" Width="640" Height="480"> <Grid x:Name="LayoutRoot"> <DockPanel LastChildFill="False"> <TextBlock DockPanel.Dock="Top" TextWrapping="Wrap" Text="First ExpandAll then CollapseAll. Then try to expand individual cards -- it requires two clicks, as though the internal state is out of sync with the visual state. This does not seem to occur if we don't start with the initial state of ShouldCollapseCards=True"/> <StackPanel DockPanel.Dock="Top" HorizontalAlignment="Left" Orientation="Horizontal"> <Button x:Name="ExpandButton" Content="Expand All" Click="ExpandButton_Click"/> <Button x:Name="CollapseButton" Content="Collapse All" Click="CollapseButton_Click"/> </StackPanel> <igDP:XamDataCards x:Name="DataCards" BindToSampleData="True"> <igDP:XamDataCards.ViewSettings> <igDP:CardViewSettings ShouldCollapseCards="True"/> </igDP:XamDataCards.ViewSettings> </igDP:XamDataCards> </DockPanel> </Grid></Window>
MainWindow.xaml.cs
using System;using System.Collections.Generic;using System.Text;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Shapes;using Infragistics.Windows.Editors;using Infragistics.Windows.DataPresenter;namespace CardViewTest{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { this.InitializeComponent(); // Insert code required on object creation below this point. } private void CollapseAllButton_Click(object sender, System.Windows.RoutedEventArgs e) { DataPresenterBase dataPresenter = this.datacards as DataPresenterBase; if (dataPresenter != null) { foreach (Record currentRecord in dataPresenter.Records) { currentRecord.IsContainingCardCollapsed = true; } } } private void ExpandAllButton_Click(object sender, System.Windows.RoutedEventArgs e) { DataPresenterBase dataPresenter = this.datacards as DataPresenterBase; if (dataPresenter != null) { foreach (Record currentRecord in dataPresenter.Records) { currentRecord.IsContainingCardCollapsed = false; } } } }}