Bug 53409 - REQUEST: Add a property to ContentPage or FormsApplication that indicates if the page is being rendered for the Previewer or runtime
Summary: REQUEST: Add a property to ContentPage or FormsApplication that indicates if ...
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: unspecified
Hardware: PC Mac OS
: Normal enhancement
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-03-16 18:18 UTC by Rob DeRosa
Modified: 2017-06-21 14:05 UTC (History)
6 users (show)

Tags: xamexttriage, previewer
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Rob DeRosa 2017-03-16 18:18:25 UTC
It would be super helpful to be able to determine if the ContentPage/ContentView is being rendered at runtime or for the Previewer.

Use cases for this would be:

- When animations manipulate your views/controls but you want to see the after-animation in the Previewer. Example here: https://github.com/xamarin/Sport/blob/master/Sport.Mobile.Shared/Pages/WelcomeAuthentication/EnablePushPage.xaml.cs#L23

- If you are setting your BindingContext in C#, you may want to set a mock VM instead of the runtime VM.

- Properties getters don't play nice in Preview mode but work fine at runtime
Comment 1 Rob DeRosa 2017-03-16 18:19:24 UTC
Ideally, something like the Windows Forms .IsDesignMode property.... like FormsApplication.Current.IsPreviewMode
Comment 3 David Ortinau [MSFT] 2017-06-01 17:36:35 UTC
I've added this to the team backlog. 

There is also a proposal from John Miller in Evolution, though we need to decide on the actual naming and implementation. 

https://forums.xamarin.com/discussion/87071/provide-an-api-for-checking-if-in-design-mode-or-not-when-using-the-xaml-previewer#latest
Comment 4 Alan McGovern 2017-06-01 17:42:18 UTC
I would hope we replicate one of the existing mechanisms exposed by WPF/UWP. Converging the feature set seems like the right approach!