Search Results

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

Page 10/48 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • ItemsControl.ItemsSource MVVM perormance

    - by bitbonk
    I have an (non-virtualized) ItemsControl that binds its ItemsSource to a ObeservableCollection of ViewModel instances. Now once the large amount Model instances is loaded all the ViewModel complemnents needs to be added to that ObservableCollection. How can I add a large amount of ViewModels without making the UI Thread hang? I suppose the UI Thread hangs because each time a new item is added the ItemsControl needs to update itself and does layout etc. over and over again. Should I suspend the binding add all items and then resume? If so, how? Should I override the ObservableCollection to implement an AddRange so only 1 CollectionChanged Event is fired for adding multiple items? Or alternatively just replace the whole collection? Or is it better to add each items separately and call Dispatcher.Invoke for each item separately? So I would unblock frequently. How do you handle large dynamic lists that can not be virtualized?

    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

  • TypeInitializeException on MVVM pattern

    - by Mohit Deshpande
    System.TypeInitializationException was unhandled Message=The type initializer for 'SmartHomeworkOrganizer.ViewModels.MainViewModel' threw an exception. Source=SmartHomeworkOrganizer TypeName=SmartHomeworkOrganizer.ViewModels.MainViewModel StackTrace: at SmartHomeworkOrganizer.ViewModels.MainViewModel..ctor() at SmartHomeworkOrganizer.App.OnStartup(Object sender, StartupEventArgs e) in C:\Users\Mohit\Documents\Visual Studio 2010\Projects\SmartHomeworkOrganizer\SmartHomeworkOrganizer\App.xaml.cs:line 21 at System.Windows.Application.OnStartup(StartupEventArgs e) at System.Windows.Application.<.ctor>b__0(Object unused) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state) at System.Threading.ExecutionContext.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.Run() at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run() at SmartHomeworkOrganizer.App.Main() in C:\Users\Mohit\Documents\Visual Studio 2010\Projects\SmartHomeworkOrganizer\SmartHomeworkOrganizer\obj\Debug\App.g.cs:line 0 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: System.ArgumentException Message=Default value type does not match type of property 'Score'. Source=WindowsBase StackTrace: at System.Windows.DependencyProperty.ValidateDefaultValueCommon(Object defaultValue, Type propertyType, String propertyName, ValidateValueCallback validateValueCallback, Boolean checkThreadAffinity) at System.Windows.DependencyProperty.ValidateMetadataDefaultValue(PropertyMetadata defaultMetadata, Type propertyType, String propertyName, ValidateValueCallback validateValueCallback) at System.Windows.DependencyProperty.RegisterCommon(String name, Type propertyType, Type ownerType, PropertyMetadata defaultMetadata, ValidateValueCallback validateValueCallback) at System.Windows.DependencyProperty.Register(String name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata, ValidateValueCallback validateValueCallback) at System.Windows.DependencyProperty.Register(String name, Type propertyType, Type ownerType, PropertyMetadata typeMetadata) at SmartHomeworkOrganizer.ViewModels.MainViewModel..cctor() in C:\Users\Mohit\Documents\Visual Studio 2010\Projects\SmartHomeworkOrganizer\SmartHomeworkOrganizer\ViewModels\MainViewModel.cs:line 72 InnerException: This bit of code throws a System.ArgumentException before the TypeInitializeException. It says: "Default value type does not match type of property Score": public static readonly DependencyProperty ScoreProperty = DependencyProperty.Register("Score", typeof(float), typeof(MainViewModel), new UIPropertyMetadata(0.0)); Here is the .NET property: public float Score { get { return (float) GetValue(ScoreProperty); } set { SetValue(ScoreProperty, value); } }

    Read the article

  • use Services in MVVM

    - by netmajor
    I want to use Services(WCF/RIA /Web) to take data from Entity Data Model class (maybe NHibernate class) and prepared it special for View layer binding. I have few Silverlight page, so should I create for each page separate service class ? Or create one interface and all method will implement it in one service class? Do You have some advice helped with my with services ?

    Read the article

  • Silverlight MVVM conversion from WPF

    - by IrishJoker
    I was reading this article - http://msdn.microsoft.com/en-us/magazine/dd419663.aspx And I came across this piece of code in the WPF Demo application that came with the article. This template applies a CustomerView to an instance of the CustomerViewModel class shown in the main window. <DataTemplate DataType="{x:Type vm:CustomerViewModel}"> <vw:CustomerView /> </DataTemplate> I substituted the angle brackets for square brackets - not sure how to post them. The code is in the MainWindowResourses.xaml and the code starts on line 19. Anyone know how I can do this in Silverlight ?? We don't have the DataType and I need to be able to tell the app that this View is associated with this ViewModel - so I can create a tab control with different view like the demo app. Cheers, EC

    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

  • mvvm - prismv2 - INotifyPropertyChanged

    - by depictureboy
    Since this is so long and prolapsed and really doesnt ask a coherent question: 1: what is the proper way to implement subproperties of a primary object in a viewmodel? 2: Has anyone found a way to fix the delegatecommand.RaiseCanExecuteChanged issue? or do I need to fix it myself until MS does? For the rest of the story...continue on. In my viewmodel i have a doctor object property that is tied to my Model.Doctor, which is an EF POCO object. I have onPropertyChanged("Doctor") in the setter as such: Private Property Doctor() As Model.Doctor Get Return _objDoctor End Get Set(ByVal Value As Model.Doctor) _objDoctor = Value OnPropertyChanged("Doctor") End Set End Property The only time OnPropertyChanged fires if the WHOLE object changes. This wouldnt be a problem except that I need to know when the properties of doctor changes, so that I can enable other controls on my form(save button for example). I have tried to implement it in this way: Public Property FirstName() As String Get Return _objDoctor.FirstName End Get Set(ByVal Value As String) _objDoctor.FirstName = Value OnPropertyChanged("Doctor") End Set End Property this is taken from the XAMLPowerToys controls from Karl Shifflet, so i have to assume that its correct. But for the life of me I cant get it to work. I have included PRISM in here because I am using a unity container to instantiate my view and it IS a singleton. I am getting change notification to the viewmodel via eventaggregator that then populates Doctor with the new value. The reason I am doing all this is because of PRISM's DelegateCommand. So maybe that is my real issue. It appears that there is a bug in DelegateCommand that does not fire the RaiseCanExecuteChanged method on the commands that implement it and therefore needs to be fired manually. I have the code for that in my onPropertyChangedEventHandler. Of course this isnt implemented through the ICommand interface either so I have to break and make my properties DelegateCommand(of X) so that I have access to RaiseCanExecuteChanged of each command.

    Read the article

  • WPF MVVM ViewModel constructor designmode

    - by Snake
    Right, I've got a main wpf window: <Window x:Class="NorthwindInterface.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ViewModels="clr-namespace:NorthwindInterface.ViewModels" Title="MainWindow" Height="350" Width="525"> <Window.DataContext> <ViewModels:MainViewModel /> </Window.DataContext> <ListView ItemsSource="{Binding Path=Customers}"> </ListView> </Window> And the MainViewModel is this: class MainViewModel : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged = delegate { }; public MainViewModel() { Console.WriteLine("test"); using (NorthwindEntities northwindEntities = new NorthwindEntities()) { this.Customers = (from c in northwindEntities.Customers select c).ToList(); } } public List<Customer> Customers { get;private set; } Now the problem is that in designermode I can't see my MainViewModel, it highlights it saying that it can't create an instance of the MainViewModel. It is connecting to a database. That is why (when I comment the code the problem is solved). But I don't want that. Any solutions on best practices around this?

    Read the article

  • WPF with MVVM and Prismv2 - Event Bubbling?

    - by depictureboy
    What is the best way to get an event from a child or grandchild module up to the parent Shell? For instance, if I have a view in a module that is actually 2 levels away from the Shell, and I have a Window behavior. Is the eventaggregator really the best way to do this? it seems like overkill. I just want my MainShell to watch for a change in the IsDialogOpen Property on the ViewModels in all my child modules. I feel like I am missing the trees for the forest...

    Read the article

  • implementation Services in MVVM

    - by netmajor
    I want to use Services(WCF/RIA /Web) to take data from Entity Data Model class (maybe NHibernate class) and prepared it special for View layer binding. I have few Silverlight page, so should I create for each page separate service class ? Or create one interface and all method will implement it in one service class? Do You have some advice helped with my with services ?

    Read the article

  • MVVM View Model DTOs

    - by Burt
    I have a WCF based application that uses the services to access repositories on the server side. I am passing DTOs from the server to the client and was wondering how best to make the DTOs part pf the view model. I have a workign example of just plain properties on the view model but was unsure how to deal with actual DTO objects and any possible conversion between the DTO and the Vview model properties.

    Read the article

  • MVVM, ContextMenus and binding to ViewModel defined Command

    - by Simon Fox
    Hi I am having problems with the binding of a ContextMenu command to an ICommand property in my ViewModel. The binding seems to be attaching fine...i.e when I inspect the value of the ICommand property it is bound to an instance of RelayCommand. The CanExecute delegate does get invoked, however when I open the context menu and select an item the Execute delegate does not get invoked. Heres my View (which is defined as the DataTemplate to use for instances of the following ViewModel in a resource dictionary): <UserControl x:Class="SmartSystems.DragDropProto.ProductLinkView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Proto"> <UserControl.Resources> <local:CenteringConverter x:Key="centeringConvertor"> </local:CenteringConverter> </UserControl.Resources> <UserControl.ContextMenu> <ContextMenu> <MenuItem Command="{Binding ChangeColor}">Change Color</MenuItem> </ContextMenu> </UserControl.ContextMenu> <Canvas> <Ellipse Width="5" Height="5" > <Ellipse.Fill> <SolidColorBrush Color="{Binding LinkColor}"></SolidColorBrush> </Ellipse.Fill> <Ellipse.RenderTransform> <TranslateTransform X="{Binding EndpointOneXPos, Converter={StaticResource centeringConvertor}}" Y="{Binding EndpointOneYPos, Converter={StaticResource centeringConvertor}}"/> </Ellipse.RenderTransform> </Ellipse> <Line X1="{Binding Path=EndpointOneXPos}" Y1="{Binding Path=EndpointOneYPos}" X2="{Binding Path=EndpointTwoXPos}" Y2="{Binding Path=EndpointTwoYPos}"> <Line.Stroke> <SolidColorBrush Color="{Binding LinkColor}"></SolidColorBrush> </Line.Stroke> </Line> <Ellipse Width="5" Height="5" > <Ellipse.Fill> <SolidColorBrush Color="{Binding LinkColor}"></SolidColorBrush> </Ellipse.Fill> <Ellipse.RenderTransform> <TranslateTransform X="{Binding EndpointTwoXPos, Converter={StaticResource centeringConvertor}}" Y="{Binding EndpointTwoYPos, Converter={StaticResource centeringConvertor}}"/> </Ellipse.RenderTransform> </Ellipse> </Canvas> </UserControl> and ViewModel (with uneccessary implementation details removed): class ProductLinkViewModel : BaseViewModel { public ICommand ChangeColor { get; private set; } public Color LinkColor { get; private set; } public ProductLinkViewModel(....) { ... ChangeColor = new RelayCommand(ChangeColorAction); LinkColor = Colors.Blue; } private void ChangeColorAction(object param) { LinkColor = LinkColor == Colors.Blue ? Colors.Red : Colors.Blue; OnPropertyChanged("LinkColor"); } }

    Read the article

  • WPF Prism MVVM, Internationalized Wizard Passing model data between the wizard steps

    - by Nick V
    I've found the following example of a wizard located here: http://www.codeproject.com/Articles/31837/Creating-an-Internationalized-Wizard-in-WPF Now I've spent quite some time looking at the example and i understand pretty much everything. But i can't figure out how he passes an object between the different modelViews. And as you can imagine that step is quite crucial.. In the example he uses an CupOfCoffee Object in the main wizardviewmodel and somehow manages to adjust it throughout the wizard. But i cant see anywhere how he does that. I've already tried to recreate a project like he has but no success. Could anyone tell me how he passes the objects between the different viewModels?

    Read the article

  • MVVM with animations (should I use VisualStateManager?)

    - by kennethkryger
    I've got a View.xaml with the following set in Resources-section: <DataTemplate DataType="{x:Type ViewModels:MyFirstViewModel}"> <Views:MyFirstView Content="{Binding}" /> </DataTemplate> <DataTemplate DataType="{x:Type ViewModels:MySecondViewModel}"> <Views:MySecondView Content="{Binding}"/> </DataTemplate> In the content of the View.xaml I have: <!-- SelectedMyViewModel is either set to MyFirstViewModel or MySecondViewModel --> <ContentControl Content="{Binding SelectedMyViewModel}" /> When the SelectedMyViewModel changes I'd like to have a animation, so that the current view is faded out and the new view is faded in... Somehow I feel this should be possible via the VisualStateManager - but I can't figure out how! This is a WPF 4.0 project...

    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

  • I've got a ComboBox that's giving me grief in WPF using the MVVM pattern

    - by Mike
    Here's my code: <ComboBox Grid.Column="1" Grid.Row="9" ItemsSource="{Binding Path=PriorityEntries}" SelectedItem="{Binding Path=Priority,Mode=TwoWay}"/> The comboBox is bound properly with PriorityEntries, and when i change the value of the comboBox the "set" of the bound property(Priority) is called setting it to what it needs to be. However, when i close the UserControl that this combobox resides, it calls the set property again with a value of null and then sets what the selectedItem was to null. Why is the comboBox being bound again when I close the usercontrol. I tried setting the mode to OneTime, but that won't reflect any changes...

    Read the article

  • Silverlight MVVM ListBoxItem IsSelected

    - by Lee
    I have a collection of ViewModels bound to a ListBox. I am trying to bind the IsSelected properties of each together. In WPF it works by setting the style: <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" /> </Style> This does not work in Silverlight. How can I accomplish this?

    Read the article

  • Storing entity in XML, using MVVM to read/write in WPF Application

    - by Christian
    Say I've a class (model) called Instance with Properties DatbaseHostname, AccessManagerHostname, DatabaseUsername and DatabasePassword public class Instance { private string _DatabaseHostname; public string DatabaseHostname { get { return _DatabaseHostname; } set { _DatabaseHostname = value; } } private string _AccessManagerHostname; public string AccessManagerHostname { get { return _AccessManagerHostname; } set { _AccessManagerHostname = value; } } private string _DatabaseUsername; public string DatabaseUsername { get { return _DatabaseUsername; } set { _DatabaseUsername = value; } } private string _DatabasePassword; public string DatabasePassword { get { return _DatabasePassword; } set { _DatabasePassword = value; } } } I'm looking for a sample code to read/write this Model to XML (preferably linq2XML) = storing 1:n instances in XML. i can manage the the view and ViewModel part myself, although it would be nice if someone had a sample of that part too..

    Read the article

  • Following Domain Driven Design with MVVM/WPF

    - by msfanboy
    Hello, I have plain POCOs here and as INotifyPropertyChanged is a Interface for the Views need its implemented in the ViewModel not the Model. Now I want to show validation errors in the View beside every textbox the user typed in data. I do not want to implemented the IDataErrorInfo interface in my Models because lets assume I am not allowed to touch them as they come from another Service/Supplier. I do not want to put my IsCustomerFirstNameLenthValid Method into the Model because I could not have access to it or I just dont want to pollute my Models with interface`s having nothing to do there! How can I validate my naked POCO`s in the ViewModel and forward the results to the View by showing validation errors ?

    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

  • Bi-directional view model syncing with "live" collections and properties (MVVM)

    - by Schneider
    I am getting my knickers in a twist recently about View Models (VM). Just like this guy I have come to the conclusion that the collections I need to expose on my VM typically contain a different type to the collections exposed on my business objects. Hence there must be a bi-directional mapping or transformation between these two types. (Just to complicate things, on my project this data is "Live" such that as soon as you change a property it gets transmitted to other computers) I can just about cope with that concept, using a framework like Truss, although I suspect there will be a nasty surprise somewhere within. Not only must objects be transformed but a synchronization between these two collections is required. (Just to complicate things I can think of cases where the VM collection might be a subset or union of business object collections, not simply a 1:1 synchronization). I can see how to do a one-way "live" sync, using a replicating ObservableCollection or something like CLINQ. The problem then becomes: What is the best way to create/delete items? Bi-directinal sync does not seem to be on the cards - I have found no such examples, and the only class that supports anything remotely like that is the ListCollectionView. Would bi-directional sync even be a sensible way to add back into the business object collection? All the samples I have seen never seem to tackle anything this "complex". So my question is: How do you solve this? Is there some technique to update the model collections from the VM? What is the best general approach to this?

    Read the article

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