Skip to content

Commit 08fabf4

Browse files
author
Llifon Osian Jones
committed
Added an extra index-retrieval attempt for the transition offset extension
It has been observed that it's not always possible to retrieve the index of an item if the container is an bare ItemsControl (rather than ListView/ListBox), so this adds an extra level of robustness
1 parent 274ed83 commit 08fabf4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

MaterialDesignThemes.Wpf/Transitions/IndexedItemOffsetMultiplierExtension.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ public override object ProvideValue(IServiceProvider serviceProvider)
6868
multiplier = itemsControl.Items.IndexOf(element);
6969
}
7070

71+
if (multiplier == -1) //still not found, repeat now using datacontext
72+
{
73+
var frameworkElement = element as FrameworkElement;
74+
if (frameworkElement != null)
75+
{
76+
multiplier = itemsControl.Items.IndexOf(frameworkElement.DataContext);
77+
}
78+
}
79+
7180
return multiplier > -1 ? new TimeSpan(Unit.Ticks * multiplier) : TimeSpan.Zero;
7281
}
7382
}

0 commit comments

Comments
 (0)