mvvm-light

Exiting an App or Closing a Control When Using MVVM

别等时光非礼了梦想. 提交于 2019-12-02 20:04:31
问题 In my WPF application, I am using the ViewModelLocator without IoC. I am calling the static ViewModelLocator.Cleanup() method provided by the MVVM-Light framework from my own button which is tied to a "close window command". This Command calls the static ViewModelLocator.Cleanup() , which calls an instance Cleanup() method on my MainWindowViewModel instance. The instance Cleanup() method then sets the property to which the MainWindow binds its DataContext , to null. The setter on the property

Handling Mouse Events in MVVM in WPF

倖福魔咒の 提交于 2019-12-02 19:45:25
I am Using MVVM with WPF. i am halted in a way, i want your views about this. i am firing Mouse Events using MouseBehaviour.cs class , Is there any other way to handle Mouse Events in MVVM WPF using System.Windows; using System.Windows.Input; namespace Lovatts.MouseBehaviours { public class MouseBehaviour { #region MouseUp public static readonly DependencyProperty MouseUpCommandProperty = DependencyProperty.RegisterAttached("MouseUpCommand", typeof(ICommand), typeof(MouseBehaviour), new FrameworkPropertyMetadata(new PropertyChangedCallback(MouseUpCommandChanged))); private static void

Looking for simple MVVM Light example

两盒软妹~` 提交于 2019-12-02 19:38:18
I'm trying to learn MVVM Light and am looking for a good basic example that shows a model and how to load different views. The template I see after downloading MVVM Light has no models and only one view. (http://www.galasoft.ch/mvvm/creating/) Other things I've found are more complex and a bit confusing when all I want to see are the basics. Thanks. I have found this example helpful: http://apuntanotas.codeplex.com/ kevev22 I have personally found these to be quite useful, though they also use MEF and RIA Services which can complicate things: A Sample Silverlight 4 Application Using MEF, MVVM,

XAML - MenuFlyoutItem attached to a ListView doesn't work in WP8.1

荒凉一梦 提交于 2019-12-02 18:07:43
问题 I develop an Universal app that uses the MVVM-Lght toolkit . On a page, I show a list of comments. I would like that an user could add a new comment, and edit or delete its existing comments. For adding new comment, I use an AppBarButton on the CommandBar and it works fine. For editing and deleting the existing comments, I would like to display a MenuFlyout that offers 2 items: " edit " and " delete ". I can display the MenuFlyout but nothing happens when I click on its items... Here is my

WPF MVVM: How to update Usercontrol data [closed]

大城市里の小女人 提交于 2019-12-02 16:13:24
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . Starting with WPF and I like the MVVM pattern where I have a ViewModel locator as I'm quite used to IoC usage. However most blogs/articles say that a Usercontrol should not have a ViewModel. Which makes sense, but then I can't quite get how to update its data. For example, suppose I

MVVM-light + RIA Services best practices [closed]

夙愿已清 提交于 2019-12-02 15:18:12
I would like to start a collection of MVVM-light (w/ RIA Services) Best Practices. There are a number of items I have found to be helpful best practices or best approaches, but would like to hear from others using the MVVM-light toolkit and see what they have found as well. Please post your best practices as answers to this question. Ryan from Denver Basic Usage of MVVM-Light Intialize the DispatcherHelper in the App.cs file's Application_Startup function Create ViewModels from the BaseClass Always Create a ViewModelLocator class, which contains all your view models and is Linked in your

Exiting an App or Closing a Control When Using MVVM

心已入冬 提交于 2019-12-02 11:48:56
In my WPF application, I am using the ViewModelLocator without IoC. I am calling the static ViewModelLocator.Cleanup() method provided by the MVVM-Light framework from my own button which is tied to a "close window command". This Command calls the static ViewModelLocator.Cleanup() , which calls an instance Cleanup() method on my MainWindowViewModel instance. The instance Cleanup() method then sets the property to which the MainWindow binds its DataContext , to null. The setter on the property raises a PropertyChanged event. Curiously, setting this property to null does not cause the window to

How to handle ItemClick For Nested ListView In MVVM Pattern?

时光毁灭记忆、已成空白 提交于 2019-12-02 11:00:27
Xaml code: <Page x:Class="DemoTestApp.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:DemoTestApp" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" xmlns:vm="using:ViewModels" > <Page.DataContext> <vm:TestViewModel/> </Page.DataContext> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <ListView Name=

XAML - MenuFlyoutItem attached to a ListView doesn't work in WP8.1

隐身守侯 提交于 2019-12-02 10:42:16
I develop an Universal app that uses the MVVM-Lght toolkit . On a page, I show a list of comments. I would like that an user could add a new comment, and edit or delete its existing comments. For adding new comment, I use an AppBarButton on the CommandBar and it works fine. For editing and deleting the existing comments, I would like to display a MenuFlyout that offers 2 items: " edit " and " delete ". I can display the MenuFlyout but nothing happens when I click on its items... Here is my concerned xaml code: <ListView x:Name="myCommentaires" ItemsSource="{Binding Comments}"

MVVM light Dispatcher unit tests

北慕城南 提交于 2019-12-02 09:31:55
问题 I have the following function public void Reset() { DisableModule(); DispatcherHelper.UIDispatcher.Invoke(() => { PixelPointInfoCollection.Clear(); PixelPointInfoCollection.Add(new PointViewModel()); }); _cachedPoints.Clear(); } The following code gets stuck in the Invoke() method, when running a unit test. I saw some articles about creating a custom interface on dispatcher and mocking the dispatcher in unit tests. for example http://blog.zuehlke.com/en/mvvm-and-unit-testing/ Is there no