Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
790
Filtering XamDataTree
posted

Hi,

I am having difficulties in filtering the XamDataTree using triggers and collectionviewsource.

My tree should switch between two Modes based Mode1(Default) and Mode2.

The Object Model looks like below:

Class NodeX

{

....

ObservableCollection<NodeX> Nodes{get; set;}

bool IsSpecialNode {get;set;}

}

public ObservableCOllection<NodeX> NodeXCollection {get; set;}  ===> bounds to XamDataTree's ItemSource.

Mode1: should show all the nodes irrespective of the flag (IsSpecialNode )

Mode2: Should show only the nodes whose flag(IsSpecialNode ) is set to true

Option1:

<ig:NodeLayout Key="Nodes" TargetTypeName="NodeBase" DisplayMemberPath="Name"
IsDropTarget="{Binding Data.ViewType, ConverterParameter={x:Static data:ViewType.FolderView},Converter={StaticResource ValueEqualsParameterConverter},Source={StaticResource ArticleListBindingProxy}}" >
<ig:NodeLayout.NodeStyle>
<Style TargetType="{x:Type ig:XamDataTreeNodeControl}">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsInMode2}" Value="True" />
<Condition Binding="{Binding Path=Data.IsSpecialNode}" Value="False" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="Visibility" Value="Collapsed" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</ig:NodeLayout.NodeStyle>

</ig:NodeLayout>

Option2:

ICollectionView Mode2View;

Mode2View = CollectionViewSource.GetDefaultView(NodeXCollection.Nodes);

Mode2View = CollectionViewSource.GetDefaultView(ProductCollection);
if (IsInMode2)
{
 Mode2View.Filter = IsSpecialNode;
}
else
{
Mode2View.Filter = null;
}

Mode2View.Refresh();

public bool IsSpecialNode(object nodex)
{
ICollectionView Mode2NodesView = CollectionViewSource.GetDefaultView(((NodeX)nodex).Nodes);
Mode2NodesView .Filter = IsSpecialNode;

if (Mode2NodesView .IsEmpty)
return ((NodeX)nodex).Items.Any(item=> item.IsSpecial);

return true;
}

Both the options doesn't work. Please help me in filtering XamDataTree.

Tree Structure: (There is always one root node and we should display that always)

RootNode

     Node1

          Node2

              Node3

     Node4

Thanks,

Sreeni