Search Results

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

Page 6/48 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Modelling a checkable treeview in the MVVM model

    - by Stephen Stranded
    Hi, I am trying to create a checkable treeview control to list hierarchical data but it does not seem to work. I used the MVVM model example used by in codeplex simplified Treeview using ViewModel but it shows nothing. Here is my code. Please help. I am a newbie to WPF and the MVVM model but i very much want to use it in an urgent application. </UserControl.Resources> <Grid> <StackPanel Height="166"> <TextBlock Text="Please Display this" /> <TreeView ItemsSource="{Binding Classifications}" Height="141"> <TreeView.ItemContainerStyle> <!-- This Style binds a TreeViewItem to a TreeViewItemViewModel. --> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" /> <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" /> <Setter Property="FontWeight" Value="Normal" /> <Style.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter Property="FontWeight" Value="Bold" /> </Trigger> </Style.Triggers> </Style> </TreeView.ItemContainerStyle> <TreeView.Resources> <HierarchicalDataTemplate DataType="{x:Type local:PropertyTypeViewModel}" ItemsSource="{Binding Children}"> <StackPanel Orientation="Horizontal"> <CheckBox Focusable="false" IsChecked="{Binding isSelected}"></CheckBox> <TextBlock Text="{Binding Classification}" /> </StackPanel> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="{x:Type local:PropertyViewModel}" ItemsSource="{Binding Children}" > <StackPanel Orientation="Horizontal"> <CheckBox Focusable="false" IsChecked="{Binding isSelected}"></CheckBox> <TextBlock Text="{Binding PropertyName}" /> </StackPanel> </HierarchicalDataTemplate> <DataTemplate DataType="{x:Type local:LeaseViewModel}"> <StackPanel Orientation="Horizontal"> <CheckBox Focusable="false" IsChecked="{Binding isSelected}"></CheckBox> <TextBlock Text="{Binding TenantName}" /> </StackPanel> </DataTemplate> </TreeView.Resources> </TreeView> </StackPanel> </Grid>

    Read the article

  • ASP.NET MVC, MVVM and file uploads...

    - by Kieron
    Hi, I'm big fan of the MVVM pattern, in particular while using the ASP.NET MVC Framework (in this case v2 preview 2). But I'm curious if anyone knows how to use it when doing file uploads? public class MyViewModel { public WhatTypeShouldThisBe MyFileUpload { get; set; } }

    Read the article

  • WPF/MVVM: Delegating a domain Model collection to a ViewModel

    - by msfanboy
    A domain model collection (normally a List or IEnumerable) is delegated to a ViewModel. Thats means my CustomerViewModel has a order collection of type List or IEnumerable. No change in the list is recognized by the bound control. But with ObservableCollection it is. This is a problem in the MVVM design pattern. How do you cope with it?

    Read the article

  • How to do test-first development with MVVM

    - by Thorsten79
    How do you build WPF MVVM applications and user controls test-first? I find myself writing ungodly amounts of XAML with DataTemplates before I even get to unit-testing my viewmodels. Should I develop the whole viewmodel system first before even writing XAML for it? Any help appreciated.

    Read the article

  • MVVM Binding Password

    - by LnDCobra
    I am re-factoring my application to implement the MVVM design and i came across my first problem... Compiler won't let me bind to the Password property of the PasswordBox control. Anyone have any ideas / suggestions.

    Read the article

  • Animations and MVVM in Silverlight

    - by user275561
    OK I have looked and searched all i want to do is fire a storyboard animation from my view model onto my view. The problem is there is just simply too much boilerplate code to get a simple thing like myStoryboard.Begin(); firing. So what are the methods that you use? Currently, I am using Silverlight 3, MVVM Light.

    Read the article

  • Silverlight with MVVM Inheritance: ModelView and View matching the Model

    - by moonground.de
    Hello Stackoverflowers! :) Today I have a special question on Silverlight (4 RC) MVVM and inheritance concepts and looking for a best practice solution... I think that i understand the basic idea and concepts behind MVVM. My Model doesn't know anything about the ViewModel as the ViewModel itself doesn't know about the View. The ViewModel knows the Model and the Views know the ViewModels. Imagine the following basic (example) scenario (I'm trying to keep anything short and simple): My Model contains a ProductBase class with a few basic properties, a SimpleProduct : ProductBase adding a few more Properties and ExtendedProduct : ProductBase adding another properties. According to this Model I have several ViewModels, most essential SimpleProductViewModel : ViewModelBase and ExtendedProductViewModel : ViewModelBase. Last but not least, according Views SimpleProductView and ExtendedProductView. In future, I might add many product types (and matching Views + VMs). 1. How do i know which ViewModel to create when receiving a Model collection? After calling my data provider method, it will finally end up having a List<ProductBase>. It containts, for example, one SimpleProduct and two ExtendedProducts. How can I transform the results to an ObservableCollection<ViewModelBase> having the proper ViewModel types (one SimpleProductViewModel and two ExtendedProductViewModels) in it? I might check for Model type and construct the ViewModel accordingly, i.e. foreach(ProductBase currentProductBase in resultList) if (currentProductBase is SimpleProduct) viewModels.Add( new SimpleProductViewModel((SimpleProduct)currentProductBase)); else if (currentProductBase is ExtendedProduct) viewModels.Add( new ExtendedProductViewModels((ExtendedProduct)currentProductBase)); ... } ...but I consider this very bad practice as this code doesn't follow the object oriented design. The other way round, providing abstract Factory methods would reduce the code to: foreach(ProductBase currentProductBase in resultList) viewModels.Add(currentProductBase.CreateViewModel()) and would be perfectly extensible but since the Model doesn't know the ViewModels, that's not possible. I might bring interfaces into game here, but I haven't seen such approach proven yet. 2. How do i know which View to display when selecting a ViewModel? This is pretty the same problem, but on a higher level. Ended up finally having the desired ObservableCollection<ViewModelBase> collection would require the main view to choose a matching View for the ViewModel. In WPF, there is a DataTemplate concept which can supply a View upon a defined DataType. Unfortunately, this doesn't work in Silverlight and the only replacement I've found was the ResourceSelector of the SLExtensions toolkit which is buggy and not satisfying. Beside that, all problems from Question 1 apply as well. Do you have some hints or even a solution for the problems I describe, which you hopefully can understand from my explanation? Thank you in advance! Thomas

    Read the article

  • Localizing MVVM based WPF applications

    - by bitbonk
    What would be a good aproach to localize a MVVM based WPF allication that can change its language at runtime? Of course I could create a string property in the ViewModel for each and every string that is displayed somewhere in the View but that seems rather tedious to me. Is there a common approach/best practice for this?

    Read the article

  • Resharper Warnings with MVVM

    - by Dan Bryant
    As I implement the MVVM pattern with WPF, I'm finding that Resharper is often warning me that certain properties are never used in my ViewModels. The problem is that they are being used, but only by the data binding system. Has anyone else encountered this annoyance and is there a way to help Resharper realize that these properties are, indeed, being used? I am glad, at least, that VS 2010 properly realizes that [Import] tagged members won't "always be null", but hopefully I can fix this issue as well.

    Read the article

  • MVVM Group Radio Button

    - by LnDCobra
    What is the best way of binding a number of RadioButtons to an enum using MVVM? The only way I can think of is binding each group box's IsChecked to a property, and in the setter of that property assign a value to an enum in the view model. Any help is appreciated.

    Read the article

  • MVVM Tutorial/Example Code with internet connectivity

    - by SpikeX
    I understand the View and ViewModel portions of MVVM, but what I'm still really fuzzy on is how you connect your application to data sources on the Internet (say you're grabbing some XML or JSON from the web), and specifically, where that code goes in your application. Can someone provide or link to some example code or a tutorial that walks you through setting up a simple WPF (or Silverlight) application that fetches data from the Web?

    Read the article

  • where store event handler method in WPF - MVVM

    - by netmajor
    Hey, Where should I store event methods for button Click event ?Normally it's store in code behind of wpf page, <Button Name="myButton" Click="myButton_Click">Click Me</Button> but in MVVM it should be store in other view-model class and bind to click property of button like that?? <Button Name="myButton" Click="{Binding StaticResouces myButton_Click}">Click Me</Button>

    Read the article

  • Silverlight MVVM add record from user control

    - by strattonn
    I have a User Control for searching container numbers. If the user enters a container number that's new to the system then I want to tell the VM "I have a new record to add". The MVVM method avoids using Events to communicate with the VM as they create code-behind. Should I create a Dependency Property to trigger the VM but I don't think I've seen other controls with a "NewRecord" property? Any thoughts?

    Read the article

  • MVVM Light V3 released at #MIX10

    - by Laurent Bugnion
    During my session “Understanding the MVVM pattern” at MIX10 in Vegas, I showed some components of the MVVM Light toolkit V3, which gave me the occasion to announce the release of version 3. This version has been in alpha stage for a while, and has been tested by many users. it is very stable, and ready for a release. So here we go! What’s new What’s new in MVVM Light Toolkit V3 is the topic of the next post. Cleaning up I would recommend cleaning up older versions before installing V3. I prepared a page explaining how to do that manually. Unfortunately I didn’t have time to create an automatic cleaner/installer, this is very high on my list but with the book and the conferences going on, it will take a little more time. Cleaning up is recommended because I changed the name of some DLLs to avoid some confusion (between the WPF3.5 and WPF4 version, as well as between the SL3 and SL4 versions). More details in the section titled “Compatibility”. Installation Installing MVVM Light toolkit is the manual process of unzipping a few files. The installation page has been updated to reflect the newest information. Compatibility MVVM Light toolkit V3 has components for the following environments and frameworks: Visual Studio 2008: Silverlight 3 Windows Presentation Foundation 3.5 SP1 Expression Blend 3 Silverlight 3 Windows Presentation Foundation 3.5 SP1 Visual Studio 2010 RC Silverlight 3 Silverlight 4 Windows Presentation Foundation 3.5 SP1 Windows Presentation Foundation 4 Silverlight for Windows Phone 7 series Expression Blend 4 beta Silverlight 3 Silverlight 4 Windows Presentation Foundation 3.5 SP1 Windows Presentation Foundation 4 Feedback As usual I welcome your constructive feedback. If you want the issue to be discussed in public, the best way is through the discussion page on the Codeplex site. if you wish to keep the conversation private, please check my Contact page for ways to talk to me. Video, tutorials There are a few new videos and tutorials available for the MVVM Light toolkit. The material is listed on the Get Started page, under “tutorials”.   Laurent Bugnion (GalaSoft) Subscribe | Twitter | Facebook | Flickr | LinkedIn

    Read the article

  • How do I Insert Record MVVM through WCF

    - by DG KOL
    Hello, I’m new in MVVM Pattern (Using Galasoft MVVM Light toolkit). I’ve created a Test Project where I want to fetch some records from Database through WCF. This is working fine but I’ve failed to insert new record from View; Here is My Code: Database Table Name: TestUser (First Name, LastName) WCF (NWCustomer) Two Methods Public List<TestUser> GetAllUsers() [“LINQ2SQL Operation”] Public bool AddUser(TestUser testuser) Public bool AddUser(TestUser testuser) { try { using (DBDataContext db = new DBDataContext()) { TestUser test = new TestUser() { FirstName = testuser.FirstName, LastName = testuser.LastName }; db.TestUser.InsertOnSubmit(test); db.SubmitChanges(); } } catch (Exception ex) { return false; } return true; } Silverlight Project MODEL consists ITestUserService.cs TestUserService.cs public void AddTestTable(TestTableViewModel testuser, Action<bool> callback) { NWCustomerClient client = new NWCustomerClient("BasicHttpBinding_NWCustomer"); client.AddTestUserCompleted += (s, e) => { var userCallback = e.UserState as Action<bool>; if (userCallback == null) { return; } if (e.Error == null) { userCallback(e.Result); return; } userCallback(false); }; client.AddTestUserAsync(testuser.Model); } VIEWMODEL TestUserViewModel public TestUser User { get; private set; } public const string DirtyVisibilityPropertyName = "DirtyVisibility"; private Visibility _dirty = Visibility.Collapsed; public Visibility DirtyVisibility { get { return _dirty; } set { if (_dirty == value) { return; } _dirty = value; RaisePropertyChanged(DirtyVisibilityPropertyName); } } public TestUserViewModel (TestUser user) { User = user; user.PropertyChanged += (s, e) => { DirtyVisibility = Visibility.Visible; }; } MainViewModel public ObservableCollection<TestUserViewModel> TestTables { get; private set; } public const string ErrorMessagePropertyName = "ErrorMessage"; private string _errorMessage = string.Empty; public string ErrorMessage { get { return _errorMessage; } set { if (_errorMessage == value) { return; } _errorMessage = value; RaisePropertyChanged(ErrorMessagePropertyName); } } private ITestUserService _service; public RelayCommand< TestUserViewModel> AddTestUserRecord { get; private set; } public MainTestTableViewModel (ICustomerService service) { _service = service; TestTables = new ObservableCollection<TestTableViewModel>(); service.GetAllTestTable(HandleResult); } private void HandleResult(IEnumerable<TestTable> result, Exception ex) { TestTables.Clear(); if (ex != null) { //Error return; } if (result == null) { return; } foreach (var test in result) { var table = new TestTableViewModel(test); TestTables.Add(table); } } XAML <Grid x:Name="LayoutRoot"> <StackPanel> <TextBox Text="FirstName" /> <TextBox Text="LastName" /> <Button Content="Add Record" Command="{Binding AddTestUserRecord}" /> </StackPanel> </Grid> I want to add records into TestTable (Database Table). How do I insert record? In XAML two text box and a button control is present. Thanking you. DG

    Read the article

  • How to use a FolderBrowserDialog from a WPF application with MVVM

    - by David Work
    I'm trying to use the FolderBrowserDialog from my WPF application - nothing fancy. I don't much care that it has the Windows Forms look to it. I found a question with a suitable answer (How to use a FolderBrowserDialog from a WPF application), except I'm using MVVM. This was the answer I "implemented", except I can't get the window object and I'm just calling ShowDialog() without any parameters. The problem is this: var dlg = new FolderBrowserDialog(); System.Windows.Forms.DialogResult result = dlg.ShowDialog(this.GetIWin32Window()); In my ViewModel there the this has no GetIWin32Window() method for me to get the Window context. Any ideas on how to make this work?

    Read the article

  • MVVM: How to handle interaction between nested ViewModels?

    - by Dan Bryant
    I'm been experimenting with the oft-mentioned MVVM pattern and I've been having a hard time defining clear boundaries in some cases. In my application, I have a dialog that allows me to create a Connection to a Controller. There is a ViewModel class for the dialog, which is simple enough. However, the dialog also hosts an additional control (chosen by a ContentTemplateSelector), which varies depending on the particular type of Controller that's being connected. This control has its own ViewModel. The issue I'm encountering is that, when I close the dialog by pressing OK, I need to actually create the requested connection, which requires information captured in the inner Controller-specific ViewModel class. It's tempting to simply have all of the Controller-specific ViewModel classes implement a common interface that constructs the connection, but should the inner ViewModel really be in charge of this construction? My general question is: are there are any generally-accepted design patterns for how ViewModels should interact with eachother, particularly when a 'parent' VM needs help from a 'child' VM in order to know what to do?

    Read the article

  • WPF: Master - detail view with two datagrids and in MVVM

    - by EV
    Hi, I'm trying to write a master - detail control that consists of a master datagrid and the detail datagrid. My scenario was following - I used the SelectedItem and bound it to a property in ModelView. The problem is - the SelectedItem in ViewModel is never used, so I can't get the information which item is selected in a master datagrid and cannot fetch the data for thos selection. The code is below: <toolkit:DataGrid ItemsSource="{Binding}" RowDetailsVisibilityMode="VisibleWhenSelected" SelectedItem="{Binding SelectedItemHandler, Mode=TwoWay}"></toolkit:DataGrid> And in ViewModel private CustomerObjects _selectedItem; public CustomerObjects SelectedItemHandler { get { return _selectedItem; } set { OnPropertyChanged("SelectedItem"); } } The code in SelectedItemHandler is never used. What could be the problem? Should I use another approach to create master - detail in MVVM?

    Read the article

  • WPF databind Image.Source in MVVM

    - by BrettRobi
    I'm using MVVM and am trying to databind the Source property of Image to my ViewModel in such a way that I can change the icon on the fly. What is the best pattern to follow for this? I still have the flexibility to change my ViewModel to suit, but I don't know where to start in either the xaml or ViewModel. To be clear, I don't want my ViewModel to know about the specific images (that's for the View to know), just the state that triggers different images. For now I have just two states, lets say Red and Green. Should I create an Enum property or a bool? And then how do I databind to switch the image source?

    Read the article

  • Repository Pattern with Entity Framework 3.5 and MVVM

    - by Ravi
    I am developing a Database File System. I am using - .Net framework 3.5 Entity Framework 3.5 WPF with MVVM pattern The project spans across multiple assemblies each using same model. One assembly,let's call it a "server", only adds data to the database using EF i.e. same model.Other assemblies (including the UI) both reads and writes the data.The changes made by server should immediately reflect in other assemblies. The database contains self referencing tables where each entity can have single OR no parent and (may be) some children. I want to use repository pattern which can also provide some mechanism to handle this hierarchical nature. I have already done reading on this on Code Project. It shares the same context(entities) everywhere. My question is - Should I share the same context everywhere? What are the advantages and disadvantages of doing that?

    Read the article

  • Page navigation in silverlight 4 using MVVM pattern

    - by Archie
    Hello, I have a a navigation application developed in Silverlight 4. It has a main page which contains a frame. I load a particualr view in that frame and I know that I can use NavigationService to navigate to other page which would be loaded in the same frame. But my question is how it can be done using MVVM? To get the frame do I need to pass the reference of the page? Also, as per my knowledge one view is not aware of any other views. So what is the best way to make them aware of each other? I have heard of Controller and Mediator but how shall I implement them so as to get the Frame of the mainpage? It would be very helpful if anyone can give me the example or probably sample code for this. Thanks in advance.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >