How can I get MVVM Light to work nicely with a Grouped Items Page in Metro? - mvvm-light

I am trying to implement a Metro style Grouped Items Page using the MVVM Light framework following the sample in this blog post but using a ViewModelLocator to provide blendability:
http://mikaelkoskinen.net/post/winrt-tutorial-mvvm-gridview-semanticzoom.aspx
I have got this working, unfortunately the grid itself is not showing up in the designer (which is the point of me using MVVM Light). I have bound the title without problem so I know that the viewmodel is bound correctly.
Any ideas please?

I had the same problem. The issue is, if you're using a CollectionViewSource, that it needs to be explicitly, like this:
As MVVM Light injects design-time-services into the viewmodel you'd expect this to pick up your service and push the design-time data through your viewmodel to the UI. But it doesn't.
You need to give it an explicit design-time instance for this to work:
There is a useful article about using CollectionViewSource in design mode that may help.

Related

Should children of a ContentPage be rendered too when using a custom renderer?

I’ve been using Xamarin.Forms for a bit lately and can generally get enough information following the Microsoft docs. But I seem to be stuck now that I need to create a custom renderer, so if someone could help, I’d really appreciate.
I read through the docs on creating a custom render and maybe I missed the part I’m looking for, but I’m not able to tell if as part of OnElementChanged, I also need to render all the children of the Element?
The ContentPage could have a StackLayout for example with several child elements. If I dont have to render these, how do they get rendered/laid-out?
No, you don't need to render ContentPage's children.
When you create a Custom Renderer you are only extending Xamarin's renderer, meaning you only add functionality (unless you explicitly change something, like redefining a property).
So, basically, the ContentPage render/lay-out the children the same way it renders/lays-out without the Custom Renderer.
Answering your second question, actually the layout and positioning is done without renderers, as said here Xamarin.Forms Layouts.
If you want to dig deeper, you can try to understand how the ContentView (it's the easier one) is positioned by reading the source code. Here the TemplatedView (ContentView's base class) is calling LayoutChildIntoBoundingRegion for each of its children: TemplatedView.
Then this line on the LayoutChildIntoBoundingRegion calls the Layout method of the view: Layout.
The VisualElement.Layout method only gets the rectangle and sets the Bounds of the view (Layout Method). The Bounds setter is called: Setter.
Well, now you can go on and explore more of the source code if you want, but I think you got the idea ;)
Hope it helps!

Xamarin.Forms ExportRenderer vs ExportCell

I am trying to get better understanding of Xamarin.Forms renderers. I know what they are. They create a native view based on input from Xamarin Forms. You put in a Xamarin Forms ViewCell, and you get back a Android View or iOS UITableViewCell, or Windows DataTemplate. I get that.
But I have seen code using ExportRenderer and other code using ExportCell and I dont know what is the difference. When to use one over the other?
Xamarin documentation/page search is not finding either one.
They usage is identical:
[assembly: ExportRenderer(typeof(MyXamarinFormsElementType), typeof(MyNativeRendererType))]
[assembly: ExportCell(typeof(MyXamarinFormsElementType), typeof(MyNativeRendererType))]
In fact, in my code, I have a ListView with ItemCellRenderer and I tried adding either of these two assembly attributes and there is no visible difference.
As I said, Xamarin API provides zero information on this.

Does ReactiveUI for Xamarin supports ViewModel to ViewModel Navigation

I am in process of learning Reactive UI for Xamarin and going through the documentation. However was not able to find that does it supports ViewModel to ViewModel Navigation. Is there any example application for same.
At the moment navigation support for Xamarin forms is somewhat limited. So is is not possible to select if a Page should be Pushed Modal or not.
After trying to use RxUI nagivation I surrendered and now use RxUI together with xamvvm framework to deal with Page/ViewModel creation and ViewModel based navigation.
Check it out https://github.com/xamvvm/xamvvm/wiki
Please have a look at this issue: https://github.com/reactiveui/ReactiveUI/issues/1048 There are ways to do it but you'll have to implement it yourself.
You can do it natively by following approach described here https://blog.kloud.com.au/2018/05/15/data-first-approach-in-xamarin-forms/

Additional checkboxes/radiobutton required for treeview

I understand that treeview in asp.net comes with checkboxes option for usage. However, in my application, I will require 2 additional checkboxes or radiobutton on the righthand side of each leaf node of my treeview.
However, I seem to be unable to find a solution to this requirement, and i think treeview structure does not support this feature.
I'm new to asp and I'm not sure if there is any other class which i can use upon to implement this feature.
Hope I can have some ideas from you guys to implement this
All help is appreciated
Thanks!
Regards
bernerd
The tree view control is quite limited however I've found this project http://www.codeproject.com/Articles/43057/ASTreeView-Free-ASP-NET-TreeView-Control which has extended its functionality - check out the reference and see if it provides what you need OR use it as a base to extend it as your scope requires!

IValueConverter not working in blend design

I am using Blend 4. I am having a list item which i am binding to sample dataset VM using this approach, which works fine. The issue is with the IValueConverter applied to binding. Blend doesn't seem to process the converter in design time UI. Is it possible for Blend to process data using converters in design time?
This isn't an answer per-se but it might still help you.
What I do in these situations is stick a breakpoint in the Convert method, attach the debugger to Blend.exe and open the offending Xaml (in Blend). It's a real nice trick for solving some of these blendability issues.
HTH.

Resources