I've a page view which has TabView and each tabview item is a separate view, containing list.
<TabView>
<TabViewItem HeaderText="Comments">
<TabViewItem.Content>
<local:CommentsListView/>
</TabViewItem.Content>
</TabViewItem>
<TabViewItem HeaderText="Stock">
<TabViewItem.Content>
<local:StockListView/>
</TabViewItem.Content>
</TabViewItem>
<TabViewItem HeaderText="Labour">
<TabViewItem.Content>
<local:LabourListView/>
</TabViewItem.Content>
</TabViewItem>
</TabView>
In each child view I've enabled pulldown and pulldown command in each view is pointing to the same 'RefreshCommand'. I want RefreshCommand to be called once no matter from which view pulldown was performed.
Problem is that if I have say 5 child views then refresh command is called 5 times. Obviously I could bind 5 different commands which calls the same method, but would be nice if I could reuse same command.
Is this possible?
Edit: added sample of view in each tab. They all are the same except pointing to different ItemSource:
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="http://prismlibrary.com"
prism:ViewModelLocator.AutowireViewModel="True"
xmlns:custom="clr-namespace:Controls"
xmlns:converter="clr-namespace:Converters"
x:Class="CommentsListView">
<ContentView.Resources>
<ResourceDictionary>
<converter:NegateBooleanConverter x:Key="inverter" />
</ResourceDictionary>
</ContentView.Resources>
<custom:ObjectGridView
x:Name="commentsListView"
ItemsSource="{Binding CommentsList}"
IsPullToRefreshEnabled="{Binding InEditMode, Converter={StaticResource inverter}}"
IsRefreshing="{Binding IsRefreshing, Mode=TwoWay}"
PullToRefreshCommand="{Binding RefreshCommand}"
RowTapCommand="{Binding CommentTapCommand}"
ShowAddButton="True"
AddButtonVisible="{Binding InEditMode}"
AddButtonCommand="{Binding AddButtonCommand}"/>
</ContentView>
question from:
https://stackoverflow.com/questions/65930531/xamarin-prism-binding-same-command-in-multiple-views 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…