0

The objects are WPF specific, but same thing...

        var v = Style.Triggers.Where(x => x is EventTrigger)
                              .Cast<EventTrigger>()
                              .Select(x => x.Actions);

At this point, I get 3 TriggerActionCollections which is correct. What I want to do next is select the items within each collection that are "is BeginStoryboard". I can't seem to work out how to select the items within Actions (the TriggerActionsCollection).

I was thinking something like this:

        var v = Style.Triggers.Where(x => x is EventTrigger)
                              .Cast<EventTrigger>()
                              .Select(x => x.Actions.Select(y => y).Where(y => y is BeginStoryboard));

But that isn't working. Any help guys?

For those non-wpf folks. Yes, there are 3 TriggerActionCollections and in one of those there is a BeginStoryBoard object. But for arguments sake I want EVERY BeginStoryBoard object flattened out.

SledgeHammer
  • 7,338
  • 6
  • 41
  • 86

2 Answers2

1

Have you tried

var v = Style.Triggers.Where(x => x is EventTrigger)
                              .Cast<EventTrigger>()
                              .SelectMany(x => x.Actions)
                              .Where(...)

SelectMany instead of Select returns single collection instead of collection of collections.

Noxor
  • 61
  • 1
  • 7
0
var v = Style.Triggers
             .OfType<EventTrigger>()
             .SelectMany(x => x.Actions)
             .OfType<BeginStoryboard>();
Michal Ciechan
  • 13,492
  • 11
  • 76
  • 118