Bind TreeView.SelectedItem to a property in the ViewModel in a WinRT app - windows-runtime

In my Windows Store XAML app I’m using the TreeView control from the WinRTXamlToolkit and I’m attempting to two-way bind the SelectedItem property to a property on a ViewModel.
Out of the box, the SelectedItem property is read only and this makes sense because the control supports Virtualization.
I have seen some folk work around this with things like attached properties, helper methods and so forth, a great example of which is seen in this question
WPF MVVM TreeView SelectedItem
But all of the questions/solutions are not based on WinRT and all of my attempts to rework the solution code for a WinRT app have proven fruitless.
So, my question is, is this possible in a WinRT app? What am I missing?
Thanks

I'd skip trying to come up with a bindable property globally for the view model and instead use the IsSelectedBindingPath and IsExpandedBindingPath properties of the TreeView as in the debugging tools' example of the control's usage. Then when you want to select/expand an item from the view model - use a method similar to SelectItem() in my view model where I essentially set IsExpanded/IsSelected to true in item/node view models throughout the path from the root of the view model tree and load the content of the tree if the nodes in the expected path do not exist.

Related

Node element not in instance tree

I'm trying to hide some elements of a model using the Forge viewer API, but I can't access some of them because their dbIds aren't found in the model instance tree.
It's very strange because I can't hide them using the context menu either, in the properties panel it shows undefined in the name, and it's also not found in the model browser panel.
Any ideas about how can I find those elements and show or hide them programmatically?
In the model that has this problem, those objects are curtain wall profiles.
In the SVF format it's common to have dbIDs without any visual representation. There might be different reasons for that but the one that's most common IMHO is instancing - you can have one object as a "template" (with no geometry), and a couple of objects (with geometries) that are "instances" of that template, inheriting its properties. That is also why the dbIDs of these "template" objects are not found in the model hierarchy.

How can you present modal UIViewControllers in MonoTouch using MvvmCross?

By adding IMvxModalTouchView to MyView, let the view become modal. But, I cannot change it at runtime. i.e. MyView must be modal every time. Is it possible to make it more flexible, let say, Show(MvxShowViewModelRequest view, bool isModal); ?
This area of MvvmCross is called "preesentation"
Other Mvvm frameworks may refer to it as "INavigationService"
Within MvvmCross, the presenter on each platform is 100% overrideable. Some examples and source code links are provided on http://slodge.blogspot.co.uk/2013/06/presenter-roundup.html
If you want to implement some custom navigation hint, then:
all ShowViewModel calls have an presentationHint parameter - https://github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/Cirrious.MvvmCross/ViewModels/MvxNavigatingObject.cs#L40
the presenters receive these hints in the PresentationValues property of the MvxViewModelRequest in the Show call

Binding a Backbone Collection to DOM element using rivets without extending backbone view

I'm new to html5. I want to bind backbone collection to DOM element using rivets without extending backbone view. I got code snippets like extending adapter, using rivets.bind but i dont know how to organize everything. Can someone explain me how to achieve this in steps?
Thanks in Advance
Update: We can do this if we follow the example provided in the link of the accepted answer.
what you want to bind is the View, not the collection. The Collection is just data, an array of models if you wish. The View is what responds to user interaction, and that's where your rivets binding will be handled.
Check out Backbone.Marionette framework as its specialized CollectionView simplifies this even further, although you may go with a standard Backbone.View too.

Flex 4.5 / Apache Flex UI Framework Architecture

Is there any framework for UI development in Flex 4.5 ? Better standard for creating UI view layers using Action script. Also how to create states and state transitions in Action script?
Is there any framework for UI development in Flex 4.5 ?
Flex is a framework for UI Development. You can read up on the Flex Component Lifecycle for more information on how it works.
Better standard for creating UI view layers using Action script.
I don't understand what you're asking for here. You want a better standard than what?
Also how to create states and state transitions in Action script?
You can create states and state transitions in ActionScript similar to how you do it in MXML. Every component has a states array; and each entry in the state array will be an instance of the State class which will have a bunch of 'commands' to add or remove children or change properties. The full list is in the state class API documentation under the related API elements header.
Setting up states in ActionScript is tedious, though.

Dynamic Tree Generation in Flex Actionscript

I am using the URL logic for creating a dynamic Tree in Flex using action script. However the output is not properly shown (Object name is shown instead of Label).
Code is available in above mentioned URL.
Please help.
Write a correct toString() implementation of your DataTreeNode, so it would have a proper display in this tree.
An example: Provided the class DataTreeNode has a data:Object field, and this object has a urlToDisplay:String property that you want displayed. Do like this:
override public function toString():String {
if (!data) return '[null]';
return data.urlToDisplay;
}
If you only rely on simple Objects or data classes, you can use the tree's labelField or labelFunction in order to read and/or format data, which is passed to the renderer. There are no new item renderer classes needed.
New renderer should be compatible with these functions!
On a site note: item renderer are not "mostly just simple MXML classes", they are component instances. It doesn't matter how there are implemented. There are best practises like avoiding data bindings in item renderers, that's why it is common to use the markup for drawing, but implementing the views behaviour according to the Flex component live cycle. you might want to read about it in the documentation, because it is a necessary read for a Flex developer.
You will have to write an ItemRenderer that tells your tree how it should display the components. ItemRenderers are mostly just simple MXML classes that access one item each and display the data in any way you want. You will have to assign the ItemRenderer to your component.
See this article:
http://help.adobe.com/en_US/flex/using/WS03d33b8076db57b9-23c04461124bbeca597-8000.html