Search Results

Search found 4517 results on 181 pages for 'mvvm light'.

Page 8/181 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • DataGrid row and MVVM

    - by Titan
    Hi, I have a wpf datagrid with many rows, each row has some specific behaviors like selection changed of column 1 combo will filter column 2 combo, and what is selected in row 1 column 1 combo cannot be selected in row 2 column 1 combo, etc... So I am thinking of having a view model for the main datagrid, and another for each row. Is that a good MVVM implementation? It is so that I can handle each row's change event effectively. Question is, how do I create "each row" as a user control view? within the datagrid. I want to implement something like this: <TreeView Padding="0,4,12,0"> <controls:CommandTreeViewItem Header="Sales Orders" Command="{Binding SelectViewModelCommand}" CommandParameter="Sales Orders"/> </TreeView> Where instead of a TreeView I want a datagrid, and instead of controls:CommandTreeViewItem a datagrid row in WPF. Thanks in advance.

    Read the article

  • MVVM in a canvas with usercontrols

    - by Mauro Destro
    I have a MVVM WPF application that basically wants to be a single line diagram designer for an electrical distribution network. I have a canvas that must contains transformers, circuit breaker, lines and cables. My big problem is the design... How can i start? I think about a DesignerView, DesignerViewModel that contains an ObservableCollection of IDesignerItemViewModel that is my base class for all the element. But in this case I have to use ItemsControl to bind the content of the canvas to my collection but the pros is that I don't have to create usercontrol for each element but i'll solve most of the problems with DataTemplate (i suppose). Each element viewmodel mantain a link to a model persisted in a repository where i mantain my logical tree. Any hint about how to proceed, I have looked at many DiagramCanvas example but all of those use simple items most like simple rectangle...

    Read the article

  • navigate through pages in mvvm in silverlight 4

    - by Archie
    Hello, I have been searching on how to navigate through the pages in silverlight 4 (navigation application) when I have implemented MVVM pattern. But nothing I found satisfied me. I have a main page which has frame in it. In that frame I load home page which does simple URI mapping. But now I want to go to New Page on button's click event. Can anyone please give me the solution? Its urgent. Thanks.

    Read the article

  • Why use MVVM???

    - by LnDCobra
    Okay, I have been looking into MVVM pattern, and each time I have previously tried looking into it, I gave up for a number of reasons: Unnecessary Extra Long Winded Coding No apparent advantages for coders (no designers in my office. Currently only myself soon to be another coder) Not a lot of resources/documentation of good practices! (Or at least hard to find) Cannot think of a single scenario where this is advantageous. I'm about to give up on it yet again, and thought I'd ask to see if someone answer the reasons above. I honestly can't see an advantage of using this for a single/partner coding. Even in complex projects with 10's of windows. To me the DataSet is a good enough view and binding like in the answer by Brent following question

    Read the article

  • MVVM - implementing 'IsDirty' functionality to a ModelView in order to save data

    - by Brendan
    Hi, Being new to WPF & MVVM I struggling with some basic functionality. Let me first explain what I am after, and then attach some example code... I have a screen showing a list of users, and I display the details of the selected user on the right-hand side with editable textboxes. I then have a Save button which is DataBound, but I would only like this button to display when data has actually changed. ie - I need to check for "dirty data". I have a fully MVVM example in which I have a Model called User: namespace Test.Model { class User { public string UserName { get; set; } public string Surname { get; set; } public string Firstname { get; set; } } } Then, the ViewModel looks like this: using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Windows.Input; using Test.Model; namespace Test.ViewModel { class UserViewModel : ViewModelBase { //Private variables private ObservableCollection<User> _users; RelayCommand _userSave; //Properties public ObservableCollection<User> User { get { if (_users == null) { _users = new ObservableCollection<User>(); //I assume I need this Handler, but I am stuggling to implement it successfully //_users.CollectionChanged += HandleChange; //Populate with users _users.Add(new User {UserName = "Bob", Firstname="Bob", Surname="Smith"}); _users.Add(new User {UserName = "Smob", Firstname="John", Surname="Davy"}); } return _users; } } //Not sure what to do with this?!?! //private void HandleChange(object sender, NotifyCollectionChangedEventArgs e) //{ // if (e.Action == NotifyCollectionChangedAction.Remove) // { // foreach (TestViewModel item in e.NewItems) // { // //Removed items // } // } // else if (e.Action == NotifyCollectionChangedAction.Add) // { // foreach (TestViewModel item in e.NewItems) // { // //Added items // } // } //} //Commands public ICommand UserSave { get { if (_userSave == null) { _userSave = new RelayCommand(param => this.UserSaveExecute(), param => this.UserSaveCanExecute); } return _userSave; } } void UserSaveExecute() { //Here I will call my DataAccess to actually save the data } bool UserSaveCanExecute { get { //This is where I would like to know whether the currently selected item has been edited and is thus "dirty" return false; } } //constructor public UserViewModel() { } } } The "RelayCommand" is just a simple wrapper class, as is the "ViewModelBase". (I'll attach the latter though just for clarity) using System; using System.ComponentModel; namespace Test.ViewModel { public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable { protected ViewModelBase() { } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = this.PropertyChanged; if (handler != null) { var e = new PropertyChangedEventArgs(propertyName); handler(this, e); } } public void Dispose() { this.OnDispose(); } protected virtual void OnDispose() { } } } Finally - the XAML <Window x:Class="Test.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:Test.ViewModel" Title="MainWindow" Height="350" Width="525"> <Window.DataContext> <vm:UserViewModel/> </Window.DataContext> <Grid> <ListBox Height="238" HorizontalAlignment="Left" Margin="12,12,0,0" Name="listBox1" VerticalAlignment="Top" Width="197" ItemsSource="{Binding Path=User}" IsSynchronizedWithCurrentItem="True"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Path=Firstname}"/> <TextBlock Text="{Binding Path=Surname}"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> <Label Content="Username" Height="28" HorizontalAlignment="Left" Margin="232,16,0,0" Name="label1" VerticalAlignment="Top" /> <TextBox Height="23" HorizontalAlignment="Left" Margin="323,21,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" Text="{Binding Path=User/UserName}" /> <Label Content="Surname" Height="28" HorizontalAlignment="Left" Margin="232,50,0,0" Name="label2" VerticalAlignment="Top" /> <TextBox Height="23" HorizontalAlignment="Left" Margin="323,52,0,0" Name="textBox2" VerticalAlignment="Top" Width="120" Text="{Binding Path=User/Surname}" /> <Label Content="Firstname" Height="28" HorizontalAlignment="Left" Margin="232,84,0,0" Name="label3" VerticalAlignment="Top" /> <TextBox Height="23" HorizontalAlignment="Left" Margin="323,86,0,0" Name="textBox3" VerticalAlignment="Top" Width="120" Text="{Binding Path=User/Firstname}" /> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="368,159,0,0" Name="button1" VerticalAlignment="Top" Width="75" Command="{Binding Path=UserSave}" /> </Grid> </Window> So basically, when I edit a surname, the Save button should be enabled; and if I undo my edit - well then it should be Disabled again as nothing has changed. I have seen this in many examples, but have not yet found out how to do it. Any help would be much appreciated! Brendan

    Read the article

  • Does Adorner breaks MVVM?

    - by Padu Merloti
    I'm developing a WPF app using MVVM. Most of my views have only xaml markup and nothing (except default boilerplate) on code behind. All except one view that I use adorners to "blacken" the screen when I want to make the whole screen disabled. private void Window_Loaded(object sender, RoutedEventArgs e) { //todo: transfer to modelview contentAreaAdorner = AdornerLayer.GetAdornerLayer(contentArea); waitingAdorner = new WaitingAdorner(contentArea); } Is that ok? Or is there a better way to implement this in my viewmodel?

    Read the article

  • How would MVVM be for games?

    - by Benny Jobigan
    Particularly for 2d games, and particularly silverlight/wpf games. If you think about it, you can divide a game object into its view (the graphic on the screen) and a view-model/model (the state, ai, and other data for the object). In silverlight, it seems common to make each object a user control, putting the model and view into a single object. I suppose the advantage of this is simplicity. But, perhaps it's less clean or has some disadvantages in terms of the underlying "game engine". What are your thoughts on this matter? What are some advantages and disadvantages of using the MVVM pattern for game development? How about performance? All thoughts are welcome.

    Read the article

  • MVVM - what is the ideal way for usercontrols to talk to each other

    - by Sandbox
    I have a a user control which contains sevral other user controls. I am using MVVM. Each user control has a corresponding VM. How do these user controls send information to each other. I want to avoid writing any code in the xaml code behind. Particularly I am interested in how the controls (inside the main user control) will talk to each other and how will they talk to the container user control. EDIT: I know that using events-delegates will help me solve this issue. But, I want to avoid writing any code in xaml code-behind.

    Read the article

  • Handling Dialogs in WPF with MVVM

    - by Ray Booysen
    In the MVVM pattern for WPF, handling dialogs is one of the more complex operations. As your view model does not know anything about the view, dialog communication can be interesting. I can expose an ICommand that when the view invokes it, a dialog can appear. Does anyone know of a good way to handle results from dialogs? I am speaking about windows dialogs such as MessageBox. One of the ways we did this was have an event on the viewmodel that the view would subscribe to when a dialog was required. public event EventHandler<MyDeleteArgs> RequiresDeleteDialog; This is OK, but it means that the view requires code which is something I would like to stay away from.

    Read the article

  • How to manage toolbars with mvvm and WPF

    - by Michael Stoll
    I'm looking for a smooth method of managing toolbars (and menus) with mvvm in WPF. Consider an UI with tabbed workspaces and heterogenous content (like Visual Studio). There the toolbars should be hidden or visible depending on the active tab. How would you design the view viewmodel for the toolbars? I'd use a collection of toolbar-viewmodels and bind the ToolbarTray to it, but afaik that's not possible. Any recommendations are apreciated. Links to samples, best practice papers, etc. are welcome.

    Read the article

  • Where to put WPF specific code when using MVVM

    - by Surfbutler
    I'm just getting up to speed on MVVM, but all the examples I've seen so far are binding View controls to simple non-WPF specific data types such as strings and ints. However in our app I want to be able to set a button's border brush based on a number in the Model. At the moment, I translate the number into a brush in the ViewModel to keep the View XAML only, but is that right? I don't like putting WPF specific code in the ViewModel, but equally I don't like the idea of putting code-behind on my View panel. Which is the best way? Thanks

    Read the article

  • Dynamically adding Views in Silverlight & MVVM

    - by dvox
    Hi all, I am starting to re-write my whole silverlight business application in the MVVM pattern; My first stop-point is this: I have a page (View1) with corresponding ViewModel1 (with a property 'IEnumerable AllData'); Now, within this View, I want to have i.e. a tree-view control, in which one node will be populated with another View2; My question is: 1. How to do it? - I can't loop through the AllData property since it is asynchronously loaded... - thus I don't know the number of View2s' to insert - I don't know how to do it from ViewModel1 :( Will I need ViewModel2 with property 'MyDataEntity CurrentData'? or I can bind to AllData property from ViewModel1 Can you help me out? Thanks

    Read the article

  • Bind value between control in different view -- WPF / MVVM

    - by Tchoupi
    Hello! in my MVVM application (in wpf) i have two view and I want to bind the context of my label on my textbox value (in the other view) SelectorView.xaml contain this control: <TextBox x:Name="tbArt" value="XX"/> DescriptionView.xaml contain this control: <label context="{binding on the tbArt value????}"> Is that possible directly without going in code behing and viewmodels ? Will the label be refresh automatically ? Thanks !

    Read the article

  • WPF + MvvM + Prism

    - by 2Fast4YouBR
    Hi all, I am new in the Wpf & Mvvm world , but I have found a couple of examples and just found that there is some different way to instantiate the model. I would like to know the best/correct way to do it. both ways are using Unity What I've foud: var navigatorView = new MainView(); navigatorView.DataContext = m_Container.Resolve<INavigatorViewModel>(); m_RegionManager.Regions["NavigatorRegion"].Add(navigatorView); What I did: var navigatorView = m_Container.Resolve<MainView>; m_RegionManager.Regions["NavigatorRegion"].Add(navigatorView); and I changed the constructor to receive viewmodel so I can point the datacontext to it: public MainView(NavigatorViewModel navigatorViewModel) { this.DataContext = navigatorViewModel; } Other examples I've found another way like: ...vm = new viewmodel ...m = new model v.model = vm; get/set DataContext cheers

    Read the article

  • Casting in MVVM Light CommandParameterValue

    - by user275561
    here is my Problem, I want to pass the integer 1 when this canvas is pressed. Every time I click the canvas, I get a An unhandled exception of type 'System.InvalidCastException' occurred in GalaSoft.MvvmLight.dll. Now I could make my life easier and just do the RelayCommand to accept a String instead of int but for the sake of learning. How would i go about doing it this way, <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <cmd:EventToCommand Command="{Binding ButtonPress}" CommandParameterValue="1" </i:EventTrigger> </i:Interaction.Triggers>

    Read the article

  • Casting in MVVM Light CommandParamterValue

    - by user275561
    here is my Problem, I want to pass the integer 1 when this canvas is pressed. Every time I click the canvas, I get a An unhandled exception of type 'System.InvalidCastException' occurred in GalaSoft.MvvmLight.dll. Now I could make my life easier and just do the RelayCommand to accept a String instead of int but for the sake of learning. How would i go about doing it this way, <i:Interaction.Triggers> <i:EventTrigger EventName="MouseLeftButtonDown"> <cmd:EventToCommand Command="{Binding ButtonPress}" CommandParameterValue="1" </i:EventTrigger> </i:Interaction.Triggers>

    Read the article

  • Can't pass a single parameter to lambda function in MVVM Light Toolkit's RelayCommand

    - by Dave
    I don't know if there's a difference between Josh Smith's and Laurent Bugnion's implementations of RelayCommand or not, but everywhere I've looked, it sounds like the Execute portion of RelayCommand can take 0 or 1 parameters. I've only been able to get it to work with 0. When I try something like: public class Test { public RelayCommand MyCommand { get; set; } public Test() { MyCommand = new RelayCommand((param) => SomeFunc(param)); } private void SomeFunc( object param) { } } I get the error: Delegate 'System.Action' does not take '1' arguments. Just to make sure I am not insane, I went to the definition of RelayCommand to make sure I didn't have some rogue implementation in my solution somewhere, but sure enough, it was just Action, and not Action<. What on earth am I missing here?

    Read the article

  • MVVM-Light EventToCommand Behavior for CheckBox Checked/Unchecked in Silverlight

    - by George Durzi
    I would like to handle the Checked and Unchecked events of a Checkbox control and execute a command in my ViewModel. I wired up an EventTrigger for both the Checked and Unchecked events as follows: <CheckBox x:Name="chkIsExtendedHr" IsChecked="{Binding Schedule.Is24Hour, Mode=TwoWay}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Checked"> <GalaSoft_MvvmLight_Command:EventToCommand CommandParameter="{Binding IsChecked, ElementName=chkIsExtendedHr}" Command="{Binding Path=SetCloseTime, Mode=OneWay}" /> </i:EventTrigger> <i:EventTrigger EventName="Unchecked"> <GalaSoft_MvvmLight_Command:EventToCommand CommandParameter="{Binding IsChecked, ElementName=chkIsExtendedHr}" Command="{Binding Path=SetCloseTime, Mode=OneWay}" /> </i:EventTrigger> </i:Interaction.Triggers> </CheckBox> I defined a RelayCommand in my ViewModel and wired up an action for it: public RelayCommand<Boolean> SetCloseTime{ get; private set; } ... SetCloseTime= new RelayCommand<bool>(ExecuteSetCloseTime); The parameter in the action for the command always resolves to the previous state of the CheckBox, e.g. false when the CheckBox is checked, and true when the CheckBox is unchecked. void ExecuteSetCloseTime(bool isChecked) { if (isChecked) { // do something } } Is this expected behavior? I have a workaround where I have separate triggers (and commands) for the Checked and Unchecked and use a RelayCommand instead of RelayCommand<bool>. Each command executes correctly when the CheckBox is checked and unchecked. Feels a little dirty though - even dirtier than having UI code in my ViewModel :) Thanks

    Read the article

  • MVVM-Light Loaded Evented Executing Twice

    - by user275561
    Let me show the code first, The Control <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Controls:MatrixGrid x:Name="matrixGrid"> <i:Interaction.Triggers> <i:EventTrigger EventName="Loaded"> <cmd:EventToCommand Command="{Binding MatrixLoaded}" CommandParameter="{Binding ElementName=matrixGrid}" /> </i:EventTrigger> </i:Interaction.Triggers> </Controls:MatrixGrid> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> In The ViewModel Class I have public RelayCommand<MatrixGrid> MatrixLoaded { get; private set; } In The Constructor of the View Model I have MatrixLoaded = new RelayCommand<MatrixGrid>(MatrixGridAction); Now When I put a Breakpoint on the Function MatrixGridAction, The breakpoint is hit twice. Am I doing something wrong or is this a bug?

    Read the article

  • Simple Binding question, unable to bind to button command in a DataTemplate using MVVM Light Toolkit

    - by deliberative assembly
    I've been attempting to bind to buttons within a DataTemplate without much success. The button does not fire. Button Click works successfully outside of the DataTemplate. Yet if I create a Click="button_click" the click button is fired. The Button Content binds perfectly as well. Example to illustrate.. Why does the command not fire? Advice on how this should be handled this? The example is a simplified version of my real problem, I am currently not using a Listbox. I only recreated the same problem with a listbox..

    Read the article

  • MVVM Light DialogMessage

    - by Cha0sEngine
    hi, im trying to use the mvvmlight DialogMessage. var message = new DialogMessage( "Confirm Delete", RemoveAddressAction) { Button = MessageBoxButton.OKCancel, Caption = "Caption??" }; VS2010 undelines the "Button = MessageBoxButton.OKCancel" line complaining about "Cannot convert source type 'System.Windows.MessageBoxButton [PresentationFramework, Version=3.0.0.0, Culture...] to target type 'System.Windows.MessageBoxItem [GalaSoft.MvvmLight, Version=3.0.0.29216, ...] And a similar issue on the code behind on the view when I try to use the DialogMessage to show the messagebox. Has anyone encountered this before? I have no clue how to fix it. Thanks.

    Read the article

  • Pass data to Child Window in Silverlight 4 using MVVM

    - by Archie
    Hello, I have a datagrid with master detail implementation as follows: <data:DataGrid x:Name="dgData" Width="600" ItemsSource="{Binding Path=ItemCollection}" HorizontalScrollBarVisibility="Hidden" CanUserSortColumns="False" RowDetailsVisibilityChanged="dgData_RowDetailsVisibilityChanged"> <data:DataGrid.Columns> <data:DataGridTextColumn Header="Item" Width="*" Binding="{Binding Item,Mode=TwoWay}"/> <data:DataGridTextColumn Header="Company" Width="*" Binding="{Binding Company,Mode=TwoWay}"/> </data:DataGrid.Columns> <data:DataGrid.RowDetailsTemplate> <DataTemplate> <data:DataGrid x:Name="dgrdRowDetail" Width="400" AutoGenerateColumns="False" HorizontalAlignment="Center" HorizontalScrollBarVisibility="Hidden" Grid.Row="1"> <data:DataGrid.Columns> <data:DataGridTextColumn Header="Date" Width="*" Binding="{Binding Date,Mode=TwoWay}"/> <data:DataGridTextColumn Header="Price" Width="*" Binding="{Binding Price, Mode=TwoWay}"/> <data:DataGridTemplateColumn> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button Content="Show More Details" Click="buttonShowDetail_Click"></Button> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate> </data:DataGridTemplateColumn> </data:DataGrid.Columns> </data:DataGrid> </DataTemplate> </data:DataGrid.RowDetailsTemplate> </data:DataGrid> I want to open a Child window in clicking the button which shows more details about the product. I'm using MVVM pattern. My Model contains a method which takes the Item name as input and retursn the Details data. My problem is how should I pass the Item to ViewModel which will get the Details data from Model? and where shoukd I open the new Child Window? In View or ViewModel? Please help.Thanks.

    Read the article

  • Linq to SQL EntitySet Binding the MVVM way

    - by Savvas Sopiadis
    Hi everybody! In a WPF application i'm using LINQ to SQL classes (created by SQL Metal, thus implementing POCOs). Let's assume i have a table User and a Table Pictures. These pictures are actually created from one picture, the difference between them may be the size, coloring,... So every user may has more than one Pictures, so the association is 1:N (User:Pictures). My problems: a) how do i bind, in a MVVM manner, a picture control to one picture (i will take one specific picture) in the EntitySet, to show it up? b) everytime a user changes her picture the whole EntitySet should be thrown away and the newly created Picture(s) should be a added. Is this the correct way? e.g. //create the 1st piture object UserPicture1 = new UserPicture(); UserPicture1.Description = "... some description.. "; USerPicture1.Image = imgBytes; //array of bytes //create the 2nd piture object UserPicture2 = new UserPicture(); UserPicture2.Description = "... another description.. "; UserPicture2.Image = DoSomethingWithPreviousImg(imgBytes); //array of bytes //Assuming that the entityset is called Pictures //add these pictures to the corresponding user User.Pictures.Add(UserPicture1); User.Pictures.Add(UserPicture2); //save changes datacontext.Save() Thanks in advance

    Read the article

  • Handle exceptions with WPF and MVVM

    - by Jon Cahill
    I am attempting to build an application using WPF and the MVVM pattern. I have my Views being populated from my ViewModel purely through databinding. I want to have a central place to handle all exceptions which occur in my application so I can notify the user and log the error appropriately. I know about Dispatcher.UnhandledException but this does not do the job as exception that occur during databinding are logged to the output windows. Because my View is databound to my ViewModel the entire application is pretty much controlled via databinding so I have no way to log my errors. Is there a way to generically handle the exceptions raised during databinding, without having to put try blocks around all my ViewModel public's? Example View: <Window x:Class="Test.TestView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="TestView" Height="600" Width="800" WindowStartupLocation="CenterScreen"> <Window.Resources> <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" /> </Window.Resources> <StackPanel VerticalAlignment="Center"> <Label Visibility="{Binding DisplayLabel, Converter={StaticResource BooleanToVisibilityConverter}}">My Label</Label> </StackPanel> </Window> The ViewModel: public class TestViewModel { public bool DisplayLabel { get { throw new NotImplementedException(); } } } It is an internal application so I do not want to use Wer as I have seen previously recommended.

    Read the article

  • RadTabControl and MVVM

    - by Jeff
    First, so you know, Silverlight 4 and VS 2010 both RC and RIA services. I'm also new to Silverlight... I have a page that has a Telerik RadTabControl on it. It will always have six tabs, i.e. the number of tabs is not data driven. The tabs are used for various admin functions. One tab for managing users with a grid and edit view, another that will have basic company info - just a few text boxes on it. The other tabs are similar to these two. I'm trying to use MVVM and can't decide on the best approach. I don't think I want one big ViewModel that handles all six tabs - that would be big, ugly and harder to maintain. Any recommendations for approaches on how to break this out? Perhaps have a ViewModel for each tab? If so, how would I (generally) go about implementing something like that? Or is there another approach that makes more sense? Thanks, Jeff

    Read the article

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