Mvvm Prism: Share data between ViewModels loaded into a region?

I've got a View containing a TabControl bound to a region "CustomerRegion". I've got a few View/ViewModels which are marked as [ViewExport(RegionName = "CustomerRegion")]. These items are loaded successfully into the TabControl. But now I need these TabItems to share some data in this TabControl (can't be global since there might be two or more of these open at one time). Any ideas how these TabItems can share data without leaving MVVM/MEF?

Mvvm notify View(Models) of closing the program

So I got my prism/mvvm/mef program running nicely along, the user is entering data in the application, then closes the application (or shuts down the computer). How can I get my View(Model) notified of the program closing / the computer shutdown, so it can either save the users data or maybe ask if these should be saved? Losing data on program close is definitely something to be avoided, and it does not make sense to save stuff on every single keypress of the user.

where does common/global data go in mvvm?

I'm trying to get my head around mvvm and came up with a test application that I think will give me a good foundation. Suppose my application has a service that goes out every minute and gets the latest flight arrival and departure information at an airport. Now suppose I have 3 different views: InboundView, OutboundView and GateView. The Inbound and Outbound views would simply display the various flight details for inbound and outbound flights that I'm sure we've all seen on the flight boards i

Mvvm CanExecute and CanExecuteChanged, I must implement these with a RelayCommand?

I am using MVVM-Light and i have my relay command working perfectly, I have just read that i should be implementing CanExecuteChanged and CanExecute. Although i am unable to find a good example. Does anyone have a good example of how to implement these. CanExecute needs to return False when it can't be executed but wouldn't just disbale the button ?? When do i execute the CanExecuteChanged? Anyone have any good examples of when to use each one, my code works without but this blog post states

MVVM, Multidimensional property, reflect change of element

I have an application in MVVM style. There is a custom control in there with a dependency property holding an ObservableCollection of A. A has a ObservableCollection of B. A and B implement INotifyPropertyChanged. When I add an object of B to A in my ViewModel, the changes will not be propagated to the control. The binding in xaml is correct, because the Bs are displayed and Mode is TwoWay.

Mvvm knockout doesn't update html after get data from ajax

I bind list of data to HTML, in each list has button for get details by ajax. I want to bind callback data to member of model, After ajax call back, object have data, view received ( ko.toJSON(d, null, 2))object. But HTML doesn't update data. I don't know what is wrong. please help. Thank you. Html: <section id="lists"> <article class="todoList"> <script type="text/html" id="person-template"> <!-- <p>Credits: <span data-bind="text: message"

Who should create view model instances in MvvmCross

Just to make it clear: I know MvvmCross is very flexible about where and how view models can be created. My question is more about proper separation of concerns, to simplify design of complex cross-platform applications. Consider we have an app with customer list and customer details. On iPad and Surface the list and details are shown on the same page, but on smaller devices customer list and details for a selected customer are split between separate pages. So we have a PCL with CustomerListVie

Mvvm Using ReactiveUI to wire up Viewmodel and model

How do I wire up Viewmodel and model the ReactiveUI way? Is there even a ReactiveUI way (like this.RaiseAndSetIfChanged for normal properties)? Regards Tobias Edit: small Sample: public class TestModel { public string TestName { get; set; } } public class TestViewModel : ReactiveObject { private TestModel _model; public TestViewModel(TestModel model) { _model = model; } public TestName { get { return _model.Name; }

Mvvm How to create view model for underlying JSON data in KendoUI

My question is ow to create a view-model object of a JSON data (parsed from a .json file) using KendoObservable object ? var viewModel = kendo.observable({ dtSource: new kendo.data.DataSource({ transport: { read: { url: "/data/SiteMaster.json", dataType: "json" } }, schema: { model: { fields: { siteName: { type: "string" }, address: { type: "str

Mvvm Data from knockout viewModel is not displaying

I am just getting started with Knockout, and I did some searching here and tried a few solutions, but was not able to find one that worked. I am trying to display a list of component instances (which happen to be called Directories - but not like folders, its a directory of contacts). Anyway, a single directory can have any number of sub-directories (so eventually recursion will be needed). I just need to display the directory hierarchy to the user, and then update it if they add a new one. Sou

Mvvm Nested Views for nested ViewModels

I am looking for a solution/mvvm framework that supports nesting ViewModels and Views. What I mean is: Each ViewModel derives from BaseViewModel ViewModels have properties that are of type BaseViewModel which are sub-ViewModels (nested inside parent ViewModel) Each ViewModel have corresponding View Views have ContentControl (control that can display templated view) corresponding to sub-ViewModels of corresponding ViewModel Now, when creating instance of ViewModel it is needed to pass appropria

Template10 MVVM IoC Inject ViewModel into Shell View

I'm looking for the best way to inject a ViewModel into a Shell view. I'm using Autofac (but I can adopt code from other IoC containers if sample is available). I have got the other VMs injecting correctly - but the method that resolves the VM using ResoleForPage method of the App class. I'm fairly new to UWP developement and any help is greatly appreciated!

Mvvm What's the idiomatic way to have multiple SwiftUI views able to update each other?

I'm an iOS and UI first-timer writing a simple app for my daughter to help her make lemonade. Three sliders control ingredients (water, sugar, lemons), and two control taste parameters (sweet and sour). The idea is that for a given sweetness and sourness, adjusting any of the ingredients sliders will update the others to meet the specified sweetness and sourness. You can see the effect below: As you can see, I've got it working but it's not a great solution; everything is happening in the view

Mvvm How can I generate classes from wsdl that work at design time in Visual Studio?

I'm doing MVVM with model classes that are generated using the visual studio wizard for "Add Service Reference". I'm trying to generate some design time sample data that will appear in the designer. The problem I face is that collection members don't get initialized, so I changed this line of generated code: [System.Runtime.Serialization.OptionalFieldAttribute()] private System.Collections.Generic.List<SDDM3.HylandService.ServiceKeyword> KeywordListField; to this: [System.Runtime.Ser

Mvvm Explicitly wait for asynchronous action to complete?

I have the following utility: class Worker { public void DoWorkAsync(Action callback) { Action work = () => Thread.Sleep(3000); AsyncCallback asyncCallback = (result) => callback(); work.BeginInvoke(asyncCallback, null); } } I use it like the following: static void Main(string[] args) { var worker = new Worker(); worker.DoWorkAsync(() => Console.WriteLine("Completed.")); Console.WriteLine("Hello world!"); Console.ReadKey(); } This will of course print He

Mvvm System.NullReferenceException when binding WPFToolkit chart

WPFToolkit thrown the exception as soon as my property on the viewmodel contains data but not when it's empty! VIEW: <UserControl x:Class="ChartView" xmlns:DV="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit" xmlns:DVC="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" <Grid> <DVC:Chart> <DVC:Chart.Series>

Kendo UI MVVM - How to get the opposite or NOT or ! of a binary variable when data-binding

What I want to do is this: <input data-bind="value: Adult.FirstName, visible: editable" /> <span data-bind="text: Adult.FirstName, visible: !editable"></span> viewModel = kendo.observable({ editable: false }); But I get the error: Uncaught SyntaxError: Unexpected token ! The only ways I’ve been able to figure out how to do it are: <input data-bind="value: Adult.FirstName, visible: editable" /> <span data-bind="text: Adult.FirstName, visible: not('editable')

multiple view models in a single page mvvmcross

I am trying to make an App for multiple platforms using Xamarin. The App uses the Mvvm structure and MvvmCross. Currently, I have various View Models and they all bind great (using MvvmCross), as long as they are in separate pages. However, I would like to make a single page that references multiple View Models. For example, a page that has few buttons each binding to methods in different View Models. I understand that to do this I should: 1) Divide the screen to different views. 2) Assig

Mvvm Register Navigation Service to Frame Element and NOT the page - WinRt Prism 2.0

Can anyone help. We are working on an app which has a consistent header and footer and therefore ideally we'll use one viewmodel for the "home page" but we want the header and footer to remain. Before we switched to starting using Prism, this was easy enough to navigate as we could control that in the Pages event and set the page.contentFrame.Navigate method to go where we wanted. Now we're using the MVVM structure (which is superb and wish I'd done it ages ago) the NavigationService class on

Mvvm How do I use RequestClose in IDialogAware in Prism 7.2.0.1367 for Xamarin Forms

I have been following the Prism 7.2.0.1367 release notes. I am able to navigate to a dialog ViewModel using dialogService.ShowDialog(NavigationStrings.MyViewModel). But when I close it, I get a null reference exception on RequestClose. I have a ViewModel like so in my Xamarin Forms project: public class MyViewModel : BaseViewModel, IDialogAware, IAutoInitialize { private DelegateCommand _closeCommand; public DelegateCommand CloseCommand => _closeCommand ?? (_closeCommand = new Del

Mvvm How I can update my adapter for RecyclerView after change my LiveData?

I created a fragment that in the onActivityCreated method fetches Firebase data by limiting the query to a calendar date. Then I place Observers on my LiveData that are inside my ViewModel and that will deliver the list to my Adapter. If I add, remove or update items in the same list, the changes are sent to firebase and the adapter reflects them on the screen. It works ok. But, I am trying to develop a filter button, which will basically change the deadline date for the Firebase query. When I s

SwiftUI and MVVM: Is using multiple viewModels in one view 'valid'?

This is more a general question: I'm working on my first SwiftUI project and using MVVM for the first time as well. After programming some views I realized that I need for almost each view two different view models. Often it's the view model for the current view and the view model of the previous/mother view. Is this "normal" or is this a hint that I've designed my project wrong and abusing MVVM? For example: I have a view where I list all flashcard decks. For this view I have a decksV

MVVM binding DataGrid (WPF Toolkit) to DataTable

I use MVVM for my project, the binding that set to DataTable work correctly at first time, but after I have update data on DataTable, it seem don't effect on DataGrid. Anyone know how to solving it?

Mvvm WPF: Setting DataContext of a UserControl with Binding not working in XAML

I'm trying to get my first WPF app working using MVVM, and I've hit a little binding problem. The setup is that I have a view & viewModel which holds User details (the parent), and to try and keep things simple I've put a section of that view into a separate view & viewModel (the child). The child view is defined as a UserControl. The issue I'm having is how to set the DataContext of the child view (the UserControl). My parent ViewModel has a property which exposes the child ViewModel

MVVM Light and SL3 Commanding

I am familar with MVVM. Actually been doing most of my learning in SL4. However, with a recent need, I have to use SL3. I am attempting to use MVVM Light v3 with SL3 and utilize commanding. The problem is that in SL3 there is no Command attribute for buttons. I managed to find an old article (http://blog.galasoft.ch/archive/2009/09/26/using-relaycommands-in-silverlight-and-wpf.aspx), but I am having trouble figuring out the ButtonBaseExtensions.Command. It appears it is no longer available in Ga

Proper MVVM way to pass info from parent to child view models

I am starting a new MVVM project with WPF, both of which I am unfamiliar with and wanted to make sure that I was using a proper MVVM approach. I have the following: I have a master user control that contains its own ViewModel and a TabControl Each Tab contains a separate user control with their own ViewModels When the MasterViewModel is created, one of its property gets set (let's call it MasterId) I need to propagate that MasterId property change from the master view model to the child view

Mvvm KnockoutJS - ViewModel Abstracion

*UPDATE* (see below) I understand the basics of KnockoutJS. When creating a table viewmodel, one would use <tr data-bind="foreach: rows"> Now I'm trying to abstract the table viewmodel, so that I can create multiple tables with the same behaviour (sorting, editing, pagination, etc..). So what I'm aiming for is something like this: HTML <div class="table a" data-bind="myTableBinding: aTableViewModel"></div> <div class="table b" data-bind="myTableBinding: anotherTableViewm

MvvmCross and Tombstoning

I am working through a basic MvvmCross (v3.0.3) example and I'm a little stuck on working out how to get state loaded back in when an application is tombstoned. At the moment I have a Portable Class Library with a single view model and one property. I also have a Windows Phone 8 application that references this PCL, binds to the view model and then binds a textblock to the property. All works well because the value of the property is displayed on screen. I have setup the WP8 project to tombston

MVVM and Castle Windsor - problems with class visibility

My "view" code-behind typically looks something like this, with the view-model being injected into its constructor:- public partial class CustomerView : UserControl { public CustomerView(CustomerViewModel viewModel) { InitializeComponent(); DataContext = viewModel; } } A view-model looks something like this, with any dependencies being injected into its constructor:- public class CustomerViewModel { ... public CustomerViewModel(SomeDependency someD

Where are class extensions placed in an MVVM pattern?

I am new to this and still trying to get a feel for the best way to do things with MVVM. I can't find an answer with Google. For convenience, I have created extensions on multiple custom classes, e.g., public static AppointmentLabel ToLabel(this textblockPatient tbp) { return tbp.appointmentlabel; } In my MVVM model, I have placed these extensions in the Model as they seem to convert one source of information into another. However, some of the custom classes are UserControl

Mvvm Prism Windows 8.1 NotifyProperyChanged does not fire?

The project: a small notice board with "post-it" messages. VB.Net, VS2013, Windows 8.1 Desktop. Prism / MVVM. The problem: the NotifyPropertyChanged event seems not to fire at all when properties change. And the messages do not show up on the noticeboard. The question: why is that so? or: what is wrong with the code below? The code: First, we have the View. It is defined like so: <prism:VisualStateAwarePage x:Name="pageRoot" x:Class="MemoBoard.Views.BoardPage" xmlns="http:/

Mvvm Setting display names in a Kendo TreeView, with a simple hierarchical datasource

I'm having trouble in displaying, or mapping, the Kendo TreeView's displaynames for my parent and child objects. The following is used as a base setup of the datasource: <div id="list-of-devices"</div> // somewhere in my script var inline = new kendo.data.HierarchicalDataSource({ data: [ { "DeviceGroupId": 1, "DeviceGroupName": "Superdeluxe Devices", "Devices": [ { "DeviceId": 1000,

Mvvm Navigate to new navigation page from ViewModel with Xamarin XLabs

I am trying to navigate to a new navigation page from a ViewModel I have this snippet in my App.cs which makes a new navigation page and binds the ViewModel to the View MainPage = new NavigationPage((Page)ViewFactory.CreatePage<MainViewModel, MainView>()); The snippet is from this article getting started xamarin forms labs xaml mvvm ioc @ "5. Register the View with the ViewFactory" But how would we do this in a ViewModel, and does it make sense to create a new page and bind the ViewM

Mvvm Current value displayed in ComboBox

I can't seem to get the current selected value to show in the ComboBox when the items in the ComboBox are custom objects from the database. I put together the following test ViewModel and View. SimpleWidgets and ObjectWidgets behave as expected. CodeWidgets (list retrieved from the database as custom 'Code' objects) never displays the SelectedCodeWidget. public class TestViewModel:BaseTabViewModel { private List<int> simpleWidgets; public List<int> SimpleWidgets

MVVM framework for Xamarin.Forms

Can someone explain What benefits an MVVM framework such as ReactiveUI or MVVM Light provides to Xamarin.Forms application? we can implement INotifyPropertyChanged in our viewmodels without using any of these frameworks. Am I missing something?

Mvvm Focus to a specific editable datagrid cell in wpf DataGrid on RowSelection

I have four columns in a datagrid and fourth column is templated and has textbox which is always editable. What i am trying to achieve here is when a row selection changes the highlighted row's fourth cell which is editable and has textbox in it should get focus. I am ok to get this done in codebehind or xaml. Here is what i did: <DataGrid Name="MyGrid" SelectionChanged="MyGrid_OnSelectionChanged" AutoGenerateColumns="False"> <DataGrid.Columns> <DataGridTex

Mvvm Xamarin Forms iOS Validate Texbox and show error

I've customized the Xamarin Forms Entry control for Android, I'm using MVVM Validation for validating my Inputs via MVVM and generate a message for each form element. Validator.AddRequiredRule(() => UserName, Messages.FieldCannotBlank); Validator.AddRequiredRule(() => Password, Messages.FieldCannotBlank); The customised entry I've used is an extended version of the Extended Entry by Xlabs. Here's the code for the Entry public class ExtendedEntry : Entry { public ExtendedEntr

Mvvm Realm and Reactive Cocoa

I am using Realm 2.0.4 and ReactiveCococa 2.5 (Objective-C API) I am trying to use MVVM. I am trying to "bind" my VM to an underlying RLMObject. Which I have done with some success. Like this. RACSignal *invalidationSignal = [[[RACObserve(self, boundedProfile.invalidated) takeUntil:self.rac_willDeallocSignal] filter:^BOOL (NSNumber *invalid) { return [invalid boolValue] == true; // We're

MVVM: Are ViewModels allowed to reference each other?

I am new to the MVVM pattern, and not sure how to handle communication between view models. There is a table view that contains multiple cell views. I created view models for the table and each cell: TableView - TableViewModel InputCellView - InputCellViewModel CheckboxCellView - CheckboxCellViewModel ..... The cells contains user input elements like text fields, checkboxes and so on. Each CellViewModel holds the data that was input by the user in the corresponding cell. My question is, wha

Mvvm Prism and Simple Injector

I'm trying a simple HelloWorld using simple inject and prism. Git Source When application starts, this error come up Failed to assign to property 'Prism.Windows.Mvvm.ViewModelLocator.AutoWireViewModel'. [Line: 8 Position: 5]" Exception thrown: 'System.MissingMethodException' in Prism.Windows.dll Exception thrown: 'Windows.UI.Xaml.Markup.XamlParseException' in HelloWorldPrism.exe WinRT information: Failed to assign to property 'Prism.Windows.Mvvm.ViewModelLocator.AutoWir

How to correctly extend an existing MVVM UI component?

In my Kotlin desktop application using TornadoFX, I have created an AudioCard layout (subclass of VBox) which has a few labels and basic audio player controls. This AudioCard has an AudioCardViewModel which handles events from the UI and an AudioCardModel which holds information like the title, subtitle, audio file path, etc. A simplified version is shown below. data class AudioCardModel( var title: String, var audioFile: File ) class AudioCardViewModel(title: String, audioFile: File)

Mvvm PropertyChangedEventHandler is null in FirePropertyChanged

I have a viewmodel named EmployeeViewModel which is inherited from ViewModelBase. here is the implementation of ViewModelBase. public event PropertyChangedEventHandler PropertyChanged; public void FirePropertyChanged(string propertyname) { var handler = PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(propertyname)); } public void FirePropertyChanged<TValue>(Expression<Func<TValue>> propertySelecto

Value of a textbox in silverlight + MVVM

I have a xaml names Customer.xaml like this: <Grid x:Name="customview" > <StackPanel x:Name="CustomPanel" > <TextBox x:Name="CustomText" /> </StackPanel> </Grid Using MVVM I have created ICustomerviewmodel and Customerviewmodel like this: public interface ICustomerviewmodel { ICommand SaveClientCommand { get; } } public class Customerviewmodel : ICustomerviewmodel , INotifyPropertyChanged { ...... private void ExecuteSaveClient() {

mvvmlight eventtocommand modifiers

I'm looking for a solution of adding modifiers to EventToCommand usign mvvm light. What I want to achieve is binding a command to let's say mouseEnter but only if the ctrl is pressed. Below I have just a mouseenter command. <i:Interaction.Triggers> <i:EventTrigger EventName="MouseEnter"> <cmd:EventToCommand Command="{Binding TestCmd}"/> </i:EventTrigger> </i:Interaction.Triggers> Any idea how to add keyboard modifier to it?

Mvvm How to navigate to a ViewModel that extends an abstract class?

I am trying to share viewmodels as much as possible using MVVMCross's suggested assembly architecture: MyApp.App └ ViewModels ├ GlobalViewModel1 └ GlobalViewModel2 (abstract) MyApp.Droid ├ Views │ ├ View1 │ └ View2 └ ViewModels └ ChildOfGlobalViewModel2 MyApp.Store ├ Views │ ├ View1 │ └ View2 └ ViewModels └ ChildOfGlobalViewModel2 I can correctly navigate to View1 and its associated viewmodel GlobalViewModel1, but it gets more complicated when I want to navigate to View2 because its

why a public constant string property in mvvmlight's default implementation?

I'm using mvvmlight and I find the default implementation (from code snippet of mvvminpcmsg) of an inpc is: /// <summary> /// The <see cref="MyProperty" /> property's name. /// </summary> public const string MyPropertyPropertyName = "MyProperty"; private bool _myProperty = false; /// <summary> /// Sets and gets the MyProperty property. /// Changes to that property's value raise the PropertyChanged event. /// This property's value is

MVVMCross: Xamarin iOS - Passing VM object during navigation

Can we pass ViewModel object during navigation in MVVMCross? I am trying to pass view model object but on the navigated page its returning null even though I could see that the object I sent was not null. ViewModel 1: private void DoEditPhoto(int imageNum) { ShowViewModel<ViewModel2>(new { index = Index,vm = this }); } ViewModel 2: private int index; ViewModel1 vm; public void Init(int index, ViewModel1 vm) { this.index = index; this.vm = vm as Vi

  1    2   3   4   5   6  ... 下一页 共 6 页