Search Results

Search found 1189 results on 48 pages for 'mvvm'.

Page 18/48 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • What is the good way of sharing specific data between ViewModels

    - by voroninp
    We have IAppContext which is injected into ViewModel. This service contains shared data: global filters and other application wide properties. But there are cases when data is very specific. For example one VM implements Master and the second one - Details of selected tree item. Thus DetailsVm must know about the selected item and its changes. We can store this information either in IAppContext or inside each concerned VM. In both cases update notifications are sent via Messenger. I see pros and cons for any of the approaches and can not decide which one is better. 1st: + explicitly exposed shared proerties, easy to follow dependencies - IAppContxt becomes cluttered with very specific data. 2nd: the exact opposite of the first and more memory load due to data duplication. May be someone can offer design alternatives or tell that one of the variants is objectively superior to the other cause I miss something important?

    Read the article

  • Using MVVM with Office365 and SharePoint 2010 REST API

    - by Sahil Malik
    SharePoint 2010 Training: more information I love JavaScript – people had pronounced this language dead a long time ago. But just like a chicken – which you eat before it’s born and after it’s dead, JavaScript – is being eaten all over the technical world, long after it’s dead! How nice! The coolest thing about JavaScript is that, There is no need for separate ActiveX controls, it is part of HTML/Browser It can interact with other DOM elements very very naturally It’s safe. And  it’s backwards and future compliant. It is no surprise thus that a number of libraries have emerged helping us work with JavaScript. But, JavaScript is not like C#. Notably, it has some biggies missing. For instance, Read full article ....

    Read the article

  • ASP.NET MVVM Handling multiple Data Transfer Objects on a single page

    - by meffect
    I have an asp.net mvc "edit" page which allows the user to make edits to the parent entity, and then also "create" child entities on the same page. Note: I'm making these data transfer objects up. public class CustomerViewModel { public int Id { get; set; } public Byte[] Timestamp { get; set; } public string CustomerName { get; set; } public etc.. public CustomerOrderCreateViewModel CustomerOrderCreateViewModel { get; set; } } In my view I have two html form's. One for Customer "edit" Http Posts, and the other for CustomerOrder "create" Http Posts. In the view page, I load the CustomerOrder "create" form in using: <div id="CustomerOrderCreate"> @Html.Partial("Vendor/_CustomerOrderCreatePartial", Model.CustomerOrderCreateViewModel) </div> The CustomerOrder html form action posts to a different controller HttpPost ActionResult than the Customer "edit" Action Result. My concern is this, on the CustomerOrder controller, in the HttpPost ActionResult [HttpPost] public ActionResult Create(CustomerOrderCreateViewModel vm) { if (!ModelState.IsValid) { return [What Do I Return Here] } ...[Persist to database code]... } I don't know what to return if the model state isn't valid. Right now it's not a problem, because jquery unobtrusive validation handles validation on the client. But what if I need more complex validation (ie: the server needs to handle the validation).

    Read the article

  • APress Deal of the Day - 13/Apr/2012 - Pro WPF and Silverlight MVVM

    - by TATWORTH
    The APress $10 deal of the day for today is "Applied WPF 4 in Context" (http://www.apress.com/9781430234708) starts with a simple introduction to WPF and then shows a complete WPF application from sketch to completed code. This APress web site states "This book can be used by a junior developer to learn WPF and understand how to architect a layered application, and it can also be used by a senior developer as a reference for developing scalable WPF applications. " - this summerises the book very effectively as it is indeed an excellent book both for learning WPF and as a reference for development. I recommend it to all Dot Net development teams.

    Read the article

  • MVVM Its Not Kool-Aid*

    [ Revised with C# and VB.NET code] Okay, first, understand that Im in the position of running through the streets yelling at folks cmere! ya gotta see this! and what Im pointing to is the incredible new invention of a laptop computer. Something that is undeniably amazing and cool, but everyone else on my block has [...]...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • MVVM Its Not Kool-Aid*

    [ Revised with C# and VB.NET code] Okay, first, understand that Im in the position of running through the streets yelling at folks cmere! ya gotta see this! and what Im pointing to is the incredible new invention of a laptop computer. Something that is undeniably amazing and cool, but everyone else on my block has [...]...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Dynamic/Generic ViewModelBase?

    - by Shimmy
    I am learning MVVM now and I understand few things (more than but few are here..): Does every model potentially exposed (thru a VM) to the View is having a VM? For example, if I have a Contact and Address entity and each contact has an Addresses (many) property, does it mean I have to create a ContactViewModel and an AddressViewModel etc.? Do I have to redeclare all the properties of the Model again in the ViewModel (i.e. FirstName, LastName blah blah)? why not have a ViewModelBase and the ContactViewMode will be a subclass of ViewModelBase accessing the Entity's properties itself? and if this is a bad idea that the View has access to the entity (please explain why), then why not have the ViewModelBase be a DynamicObject (view the Dictionary example @ the link page), so I don't have to redeclare all the properties and validation over and over in the two tiers (M & VM) - because really, the View is anyway accessing the ViewModel's fields via reflection anyway. I think MVVM was the hardest technology I've ever learned. it doesn't have out-the-box support and there are to many frameworks and methods to achieve it, and in the other hand there is no arranged way to learn it (as MVC for instance), learning MVVM means browsing and surfing around trying to figure out what's better. Bottom line, what I mean by this section is please go and vote to MSFT to add MVVM support in the BCL and generators for VMs and Vs according to the Ms. Thanks

    Read the article

  • When should I use a UserControl instead of a Page?

    - by dthrasher
    I notice that many of the WPF MVVM frameworks seem to avoid using the NavigationWindow and Page controls in favor of composing pages using nested UserControls. The NavigationWindow and Page provide easy ways to enable back and forward navigation in the journal as well as providing an easy way to pass data among pages. Most MVVM frameworks I've seen re-implement these features in various ways. Is there a specific reason to avoid using NavigationWindow and Page?

    Read the article

  • Succinct But Complete Example of WPF App?

    - by Eric J.
    Is there a succinct but complete example project or tutorial that brings together the pieces of the Microsoft stack for a complete application? WPF MVVM Business Objects EF Database I find plenty for WPF and plenty for EF, but am having trouble fully understanding how the EF generated classes relate to business objects, and how those business objects in turn fit into the MVVM pattern.

    Read the article

  • Refactoring Bloated ViewModel

    - by Holy Christ
    Hi, I am writing a PRISM/MVVM/WPF application. It's a LOB application, so there are a lot of complicated rules. I've noticed the View Model is starting to get bloated. There are two main issues. One is that to maintain MVVM, I'm doing a lot of things that feel hacky like adding a bunch of properties to my VM. The view binds to those properties to keep track of what feels like view specific information. For example, a boolean keeping track of the status of a long running process in the VM, so the view can disable some of its controls while the long running process is working. I've read that this issue could be solved with Attached Behaviors. I'll look more into that. In the example MVVM apps you see online, this isn't a big deal because they are over-simplified. The other issue is the number of commands in my VM. Right now there are four commands. I'm defining the commands in the VM using Josh Smith's RelayCommand (basically the DelegateCommand in PRISM) so all the business logic lives in the VM. I considered moving each command into separate unit of works. I'm not sure the best way to do this. Which patterns are you guys using to keep your VMs clean? I can already feel someone responding with "your view and VM is too complicated, you should break them into many view/VMs". It is certainly not too complicated from a Ux perspective - there are 2 buttons, a combobox, and a listbox. Also, from a logical perspective, it is one cohesive domain. Having said that, I'm very interested in hearing how others are dealing with this type of issue. Thanks for your input.

    Read the article

  • Enable button based on TextBox value (WPF)

    - by zendar
    This is MVVM application. There is a window and related view model class. There is TextBox, Button and ListBox on form. Button is bound to DelegateCommand that has CanExecute function. Idea is that user enters some data in text box, presses button and data is appended to list box. I would like to enable command (and button) when user enters correct data in TextBox. Things work like this now: CanExecute() method contains code that checks if data in property bound to text box is correct. Text box is bound to property in view model UpdateSourceTrigger is set to PropertyChanged and property in view model is updated after each key user presses. Problem is that CanExecute() does not fire when user enters data in text box. It doesn't fire even when text box lose focus. How could I make this work? Edit: Re Yanko's comment: Delegate command is implemented in MVVM toolkit template and when you create new MVVM project, there is Delegate command in solution. As much as I saw in Prism videos this should be the same class (or at least very similar). Here is XAML snippet: ... <UserControl.Resources> <views:CommandReference x:Key="AddObjectCommandReference" Command="{Binding AddObjectCommand}" /> </UserControl.Resources> ... <TextBox Text="{Binding ObjectName, UpdateSourceTrigger=PropertyChanged}"> </TextBox> <Button Command="{StaticResource AddObjectCommandReference}">Add</Button> ... View model: // Property bound to textbox public string ObjectName { get { return objectName; } set { objectName = value; OnPropertyChanged("ObjectName"); } } // Command bound to button public ICommand AddObjectCommand { get { if (addObjectCommand == null) { addObjectCommand = new DelegateCommand(AddObject, CanAddObject); } return addObjectCommand; } } private void AddObject() { if (ObjectName == null || ObjectName.Length == 0) return; objectNames.AddSourceFile(ObjectName); OnPropertyChanged("ObjectNames"); // refresh listbox } private bool CanAddObject() { return ObjectName != null && ObjectName.Length > 0; } As I wrote in the first part of question, following things work: property setter for ObjectName is triggered on every keypress in textbox if I put return true; in CanAddObject(), command is active (button to) It looks to me that binding is correct. Thing that I don't know is how to make CanExecute() fire in setter of ObjectName property from above code. Re Ben's and Abe's answers: CanExecuteChanged() is event handler and compiler complains: The event 'System.Windows.Input.ICommand.CanExecuteChanged' can only appear on the left hand side of += or -= there are only two more members of ICommand: Execute() and CanExecute() Do you have some example that shows how can I make command call CanExecute(). I found command manager helper class in DelegateCommand.cs and I'll look into it, maybe there is some mechanism that could help. Anyway, idea that in order to activate command based on user input, one needs to "nudge" command object in property setter code looks clumsy. It will introduce dependencies and one of big points of MVVM is reducing them. Is it possible to solve this problem by using dependency properties?

    Read the article

  • Memory leak in WPF app due to DelegateCommand.

    - by Abdullah BaMusa
    I just finished desktop apps written in WPF and c# using MVVM pattern. In this app I used Delegate Command implementation to wrap the ICommands properties exposed in my ModelView. The problem is these DelegateCommands prevent my ModelView and View from being garbage collected after closing the view. So it stays larking until I terminate the whole application. I profile the application I find it’s all about delegatecommand that keeping the modelview in memory. How could I avoid this situation and is this in nature of mvvm pattern, or it’s about my implantation of the pattern?. Thanks

    Read the article

  • WPF - Handling events from user control in View Model

    - by Vitaly
    I’m building a WPF application using MVVM pattern (both are new technologies for me). I use user controls for simple bits of reusable functionality that doesn’t contain business logic, and MVVM pattern to build application logic. Suppose a view contains my user control that fires events, and I want to add an event handler to that event. That event handler should be in the view model of the view, because it contains business logic. The question is – view and the view model are connected only by binding; how do I connect an event handler using binding? Is it even possible (I suspect not)? If not – how should I handle events from a control in the view model? Maybe I should use commands or INotifyPropertyChanged?

    Read the article

  • How many layers is too many?

    - by Nathan
    As I have been learning about software development the last 2 years the more I learn, it seems the more gray areas I am running into. One gray area I have issues with right now is trying to decide how many layers an application should have. For example, in a WPF MVVM application what fashion of layering is ok? Is the following too separated? When I mention layering I mean creating a new class library for each layer. Presentation (View) View Model Business Layer Data Access Model Layer Utility Layer Or for a non MVVM application is this too separated? Presenation Business Data Access Model Layer Utility Layer Is acceptable to run layers together and just create folders for each layer? Any coloring of this gray area would be appreciated.

    Read the article

  • The property 'IsDataSource' was not found in type 'ViewModelLocator

    - by dieter-preconsult-be
    Hello I have the following code: <UserControl x:Class="TestApp.View.ViewAlarmLog" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Custom="http://schemas.microsoft.com/wpf/2008/toolkit" xmlns:mvvm="clr-namespace:Test.ViewModel"> <UserControl.Resources> <ResourceDictionary > <ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries> <mvvm:ViewModelLocator x:Key="Locator" d:IsDataSource="True"/> </ResourceDictionary> </UserControl.Resources> the problem is dat i always get an error: The property 'IsDataSource' was not found in type 'ViewModelLocator'. " What could be the problem here ? Redgards Dieter

    Read the article

  • How to create and show views on command request?

    - by user365575
    Hi, I've started using mvvm-light toolkit , and new to WPF. My question is: I want to create an pplication where the main window includes a grid with 2 columns 1 col command and col2 will display views when each command will be pressed. i want the views to be created on command and colsed from it's own view. I've tried to figure out how to do it but with no success. I don't know how to write this kind of funconality using the mvvm light. I just know how to create main window with mainview and another view creted already on load. Please help me out.. I'm using 2008 WPF3.5 Shirly. Make me happy today.. i've just started the week!!!

    Read the article

  • Repository Design Pattern Guidance

    - by thefactor
    Let's say you have an MVVM CRM application. You have a number of customer objects in memory, through a repository. What would be the appropriate place to handle tasks that aren't associated with traditional MVVM tasks from a GUI? For example, let's say every few minutes you want to check to see if their address is valid and pop up a notification if it is not. Or you want to send out an hourly e-mail update. Or you want a window to pop up to remind you to call a customer at a specific time. Where does this logic go? It's not GUI/action-oriented, and it's not logic that would be appropriate for a repository, I think.

    Read the article

  • Binding TabControl ItemsSource to an ObservableCollection of ViewModels causes content to refresh on

    - by Brent
    I'm creating an WPF application using the MVVM framework, and I've adopted several features from Josh Smith's article on MVVM here... Most importantly, I'm binding a TabControl to an ObservableCollection of ViewModels. This means that am using a tabbed MDI interface that displays a UserControl as the content of a TabItem. The issue I'm seeing in my application is that when I have several tabs and I flip back and forth between tabs, the content is being refersh each time I change tabs. If you download Josh Smith's source code, you'll see that his app has the same problem. For example, click on the "View All Customers" button and scroll down to the bottom the ListView. Next click on the "Create New Customer" button. When you switch back to the All Customer view you'll notice that the ListView scrolls back to the top. If you switch back to the New Customer tab and place your cursor in one of the TextBoxes, then switch to All Customers tab and back, you'll notice that the cursor is now gone. I imagine that this is because I'm using an ObservableCollection, but I can't be sure. Is there any way to prevent the tab's content from refreshing when it receives the focus? EDIT: I found my problem when I ran the profiler on my application. I'm defining a DataTemplate for my ViewModels so it knows how to render the ViewModel when it is displayed in the tab... like so: <DataTemplate DataType="{x:Type vm:CustomerViewModel}"> <vw:CustomerView/> </DataTemplate> So whenever I switch to a different tab, it has to re-create the ViewModel again. I fixed it temporarily by changing my ObservableCollection of ViewModels to an ObservableCollection of UserControls. However, I would really still like to use DataTemplates if possible. Is there a way to make a DataTemplate work?

    Read the article

  • Binding TabControl ItemsSource to an ObservableCollection causes content to refresh on focus

    - by Brent
    I'm creating an WPF application using the MVVM framework, and I've adopted several features from Josh Smith's article on MVVM here... Most importantly, I'm binding a TabControl to an ObservableCollection of ViewModels. This means that am using a tabbed MDI interface that displays a UserControl as the content of a TabItem. The issue I'm seeing in my application is that when I have several tabs and I flip back and forth between tabs, the content is being refersh each time I change tabs. If you download Josh Smith's source code, you'll see that his app has the same problem. For example, click on the "View All Customers" button and scroll down to the bottom the ListView. Next click on the "Create New Customer" button. When you switch back to the All Customer view you'll notice that the ListView scrolls back to the top. If you switch back to the New Customer tab and place your cursor in one of the TextBoxes, then switch to All Customers tab and back, you'll notice that the cursor is now gone. I imagine that this is because I'm using an ObservableCollection, but I can't be sure. Is there any way to prevent the tab's content from refreshing when it receives the focus?

    Read the article

  • WPF - List items not visible in Blend when 'DisplayMemberPath' is used

    - by Andy T
    Hi, We're currently working out how to implement MVVM and I've got to the point where I've got the MVVM Light Toolkit set up in blend and can specify dummy data to be supplied if running in Blend. All good. I've created a dummy list of data. The list contains 6 instances of a very simple class called DummyItem which has Age and Name properties. Here's the main code from my 'DummyList' class: public class DummyItem{ public string Name; public int Age; public DummyItem(string name, int age){ this.Name = name; this.Age = age; } } public class DummyList : ArrayList { public DummyList() { this.Add(new DummyItem("Dummy1", 00)); this.Add(new DummyItem("Dummy2", 01)); this.Add(new DummyItem("Dummy3", 02)); this.Add(new DummyItem("Dummy4", 03)); this.Add(new DummyItem("Dummy5", 04)); this.Add(new DummyItem("Dummy6", 05)); } } Here's the operative part of my XAML. The DataContext line does work and points to the correct ViewModel. <Grid x:Name="LayoutRoot"> <ListBox x:Name="ListViewBox" DataContext="{Binding Source={StaticResource Locator}, Path=ListViewModel}" ItemsSource="{Binding TheList}" DisplayMemberPath="Name"> </ListBox> </Grid> The problem is, when I add 'DisplayMemberPath', as I have above, then I can no longer see the list items in Blend. If I remove 'DisplayMemberPath', then I see a list of objects (DummyItem) with their full path. When the app is run, everything works perfectly. It's just that in Blend itself I cannot see the list items when I use 'DisplayMemberPath'. Anyone know why I can't see the items inside Blend itself when I use DisplayMemberPath? Thanks! AT

    Read the article

  • How can I change the VisualState in a View from the ViewModel?

    - by Decker
    I'm new to WPF and MVVM. I think this is a simple question. My ViewModel is performing an asynch call to obtain data for a DataGrid which is bound to an ObservableCollection in the ViewModel. When the data is loaded, I set the proper ViewModel property and the DataGrid displays the data with no problem. However, I want to introduce a visual cue for the user that the data is loading. So, using Blend, I added this to my markup: <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="LoadingStateGroup"> <VisualState x:Name="HistoryLoading"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="HistoryGrid"> <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="HistoryLoaded"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="WorkingStackPanel"> <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> I think I know how to change the state in my code-behind (something similar to this): VisualStateManager.GoToElementState(LayoutRoot, "HistoryLoaded", true); However, the place where I want to do this is in the I/O completion method of my ViewModel which does not have a reference to it's corresponding View. How would I accomplish this using the MVVM pattern?

    Read the article

  • In M-V-VM where does my code go?

    - by Nate Bross
    So, this is a pretty basic question I hope. I have a web service that I've added through Add Service Reference. It has some methods to get list and get detail of a perticular table in my database. What I'm trying to do is setup a UI as follows: App Load Load service proxy Call the GetList(); method display the results in a ListBox control User Double Clicks item in ListBox, display a modal dialog with a "detail" view I'm extremely new to using MVVM, so any help would be greatly appreciated. Additional information: // Service Interface (simplification): interface IService { IEnumerable<MyObject> GetList(); MyObject GetDetail(int id); } // Data object (simplification) class MyObject { public int ID { get; set; } public string Name { get; set; } } I'm thinking I should have something like this: MainWindow MyObjectViewUserControl Displays list Opens modal window on double click Specific Questions: What would my ViewModel class look like? Where does the code to handle the double click go? Inside the UserControl? Sorry for the long details, but I'm very new to the whole thing and I'm not educated enough to ask the right questions. I checked out the MVVM Sample from wpf.codeplex.com and something isn't quite clicking for me yet, because it seems very confusing.

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >