Hello,
Welcome to our Microsoft Q&A platform!
You can add click event to image. when click the image send a messageCenter.
private async void SetupLargeTab()
{
var todoTabBar = (TodoTabBar)ShellItem;
var layout = new FrameLayout(Context);
var imageHandler = todoTabBar.LargeTab.Icon.GetHandler();
Bitmap bitmap = await imageHandler.LoadImageAsync(todoTabBar.LargeTab.Icon, Context);
var image = new ImageView(Context);
image.SetImageBitmap(bitmap);
image.Click += Image_Click;
layout.AddView(image);
var lp = new FrameLayout.LayoutParams(200, 200);
_bottomView.Measure((int)MeasureSpecMode.Unspecified, (int)MeasureSpecMode.Unspecified);
lp.BottomMargin = _bottomView.MeasuredHeight / 2;
layout.LayoutParameters = lp;
_shellOverlay.RemoveAllViews();
_shellOverlay.AddView(layout);
}
private void Image_Click(object sender, System.EventArgs e)
{
MessagingCenter.Send<App, string>(App.Current as App, "OneMessage","");
}
Then in the AppShell
, you can Subscribe
the message. Making a navigation, I navigate to the Page1
public partial class AppShell : Xamarin.Forms.Shell
{
public AppShell()
{
InitializeComponent();
Routing.RegisterRoute("Page1", typeof(Page1));
MessagingCenter.Subscribe<App, string>(App.Current, "OneMessage", (snd, arg) =>
{
Device.BeginInvokeOnMainThread( async() => {
//Navigation.PushAsync(new NavigationPage(new DetailsInfo(arg)));
await Shell.Current.GoToAsync("Page1");
});
});
}
}
Here is running screenshot.
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.