How to perform a page navigation action for a button which is in the Application.Resource? - windows-phone-7

I put several ApplicationBars in in the App.xaml because I want to display different ApplicationBar for different pivot pages. However, how do I perform an navigation action using the ApplicationBarIconButton? Because when I put the Navigation code in App.xaml.cs. Visual Studio gives me an error which says "An object reference is required for non-static field, method or property "System.Windows.Navigation.NavigationService.Navigate(System.Uri)".
Help please.

You can obtain the app's frame's NavigationService instance.
(Application.Current.RootVisual as PhoneApplicationFrame).Navigate();

Related

How do I access my view from within my view model with Prism?

I'm using Prism for MVVM. In my main window, I have a ribbon menu, and a tab control which shows all of my views. I want to be able to dynamically update my ribbon with contextual commands based on which view is currently selected. The binding is more complicated than just a simple list of commands (each command has an icon, subcommands, different sizes, grouping, etc.), so I think I need to somehow get a reference to my ribbon control within the main view model so I can programatically add/configure my ribbon commands. How do I get a reference to the view from within the view model?
How do I get a reference to the view from within the view model?
Use i:Interaction.Behaviors to attach the Loaded event of your view to a command on your view model and pass the view as parameter.
And then, get mad while writing the test suites for this. If I were you, I'd do everything else before I force view types into the view model...

Xamarin master detail page with static header and context menu

I need to do a master detail layout page in Xamarin which then will be used in child pages.
Please check the screenshot below:
I need to have a header part with button for notifications and a button for context menu plus a header.
What is the best approach how I can create this layout in Xamarin?
I will assume that you want to use Xamarin.Forms, instead of using Xamarin.Android and Xamarin.iOS separately.
One approach would be to use default MasterDetailPage as described here or even better to try it with Shell as described here.
Then, you would need to create your CustomNavigationPage and write a custom renderer for it.
Second approach would be to do some tricks, again creating your CustomNavigationPage with template(so that the navigation bar is always displayed) and that you change content dynamically.
Also, you would need to hide default navigation bar and attach click events to your menu button to really open up the menu.
Hope you got it clearly.
MasterDetailPage already provides nearly all functionality that you have asked for, so in some way your question isn't quite clear as you already mention MasterDetailPage. The only remaining problem I can see is how to set up a custom header, and that is than with NavigationPage.TitleView.

I get an error in Master Detail page

So I create a standard xamarin form project with a default template, then I add a Master Detail page template to the project and when I compile this project on the phone I open the side menu and when I click on Page 1 I get the error "System.InvalidCastException: Specified cast is not valid. " I do not change the default template in any way, but I get an error, I believe that it is related to the transition to Page 1 and I do not understand by what principle this transition occurs. Thanks.
enter image description here
The problem is related to the name of your view is "Page" or already there is a type in xamarin forms with the same name "Page" try making names more clear.
to resolve your problem try forcing the xamarin forms type
(Xamarin.Forms.Page)Activator.CreateInstance(item.TargetType)

What ListBox like control is used in Collections Editor of Visual Studio

I need to create a from which uses the same ListBox as the one from Collection Editor of Visual Studio (The ListBox under the Members label). Please, explain exactly which WinForms control is this and which of its properties are set?
You can see the control I am asking about under the Members: label of every collection editor form in design time of Visual Studio.
Thank you.
Hopefully this can get you started. There's other (probably better...) samples out there, but this is a basic starter which can help you get the concept:
http://msdn.microsoft.com/en-us/library/9zky1t4k%28VS.90%29.aspx
Quote:
This example shows how to create a
control named ContactCollectionEditor
that implements a custom collection
editor. The example shows how to
specify the exact type of the object
that a page developer can add to the
control's collection property when
using a custom collection editor. You
associate a collection editor with a
collection property (or the type of
the property) by applying the
EditorAttribute to the collection
property of the control.

ListDefinition Error 'ctx' is undefined

I have create a DocumentLibrary list using the SharePoint UI and export it using the SharePoint Solution Generator 2008 (VSeWSS 1.3) to a Visual Studio .NET project.
Then I have made a webpart to show items from the document library using the ListViewByQuery with som input parameters. I have put the ListViewByQuery into a Ajax UpdatePanel. The list item menu rase an error 'ctx' is undefined. ctx is defined in the schema.xml file.
Any ideas?
Work-around;
Had the same problem with a document library - to work-around I dragged the standard control part onto the page and made it non-visible (the doclibrary plugin )
Make sure that in this hidden control's view the "Name (linked to document with edit menu)" field is in the view.
That field will cause the creation of a ctx to support the edit drop-down.

Resources