Wysłanie zdarzenia LoadingPivotItem do elementów przestawnych (UserControls)
Tak więc mam Pivot i PivotItems jako UserControls. Chciałbym wiedzieć, kiedy każdy element przestawny jest nawigowany do i nawigowany od.
Zrobiłem klasę bazową (elementy przestawne ją dziedziczą), dodałem tam 2 metody (To i From), a ja mam ładowanie LoadingPivotItemCommand () w pivocie, więc wiem, który element PivotItem jest załadowany.
Ale jak rozgłaszać to wydarzenie? Próbowałem na kilka sposobów, ale wszystkie są nieważne.
void LoadingPivotItemCommand(PivotItemEventArgs args)
{
var b = args.Item.Parent as BaseUserControl;
var a = args.Item.Content as BaseUserControl;
var a1 = args.Item.Content as UserControl;
var c = args.Item.DataContext as BaseUserControl;
if (c != null)
c.OnPivotItemActivated();
}
Elementy przestawne są zdefiniowane w xaml:
<controls:PivotItem Header="{Binding Path=MainResources.Products, Source={StaticResource LocalizedStrings}, Converter={StaticResource StringToLowerCaseConverter}}"
Name="PivotItemProducts">
<Grid>
<productsView:ProductUserControl />
</Grid>
</controls:PivotItem>