mvvmlight | main purpose of the toolkit is to accelerate the creation | Form library
kandi X-RAY | mvvmlight Summary
kandi X-RAY | mvvmlight Summary
The main purpose of the toolkit is to accelerate the creation and development of MVVM applications in Xamarin.Android, Xamarin.iOS, Xamarin.Forms, Windows 10 UWP, Windows Presentation Foundation (WPF), Silverlight, Windows Phone.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of mvvmlight
mvvmlight Key Features
mvvmlight Examples and Code Snippets
Community Discussions
Trending Discussions on mvvmlight
QUESTION
This time I must be migrate MVVMLight and replace it with Microsoft.Toolkit.MVVM.
In the documentation is written there's no direct replacement for IsInDesignMode, altered or remove it.
I don't know any option to alter it, can anyone help me ?
...ANSWER
Answered 2022-Mar-27 at 10:02The general idea would be as follows, WPF for instance:
QUESTION
I am using the Microsoft.Toolkit.Mvvm nuget package for building out a WPF application on .NET Core 3.1.
I'm having an issue with binding the CommandParameter of a button within a DataGridTemplateColumn of a Datagrid.
I have a RelayCommand defined on my viewmodel, using IRelayCommand, and have a CanExecute method defined that takes a parameter. I then have the CommandParameter of the button binding bound to the data of the datagrid row.
During runtime, I am seeing the CanExecute method called for every row of my datagrid, however the parameter value is always null. If I have 5 items in my ObservableCollection, I see CanExecute called 5 times, 3 items... 3 times. In all cases the value is null.
Below is the code for my viewmodel that creates an ObservableCollection of TestModel types. A RelayCommand is created, and the criteria of the CanExecute is dumbed down to just comparing the name property of the databound model.
What I'd expect here is that for all rows except the row with name "Test2", the bound button would be enabled. The button in Test2's row would be disabled.
Here is my viewmodel, and related model class.
...ANSWER
Answered 2022-Jan-27 at 19:37What am I missing here?
The fact that CanExecute
is called before the CommandParameter
has been set.
Changing the binding to this seems to work for me:
QUESTION
I have class
...ANSWER
Answered 2022-Jan-19 at 13:53You could define a custom contract resolver to ignore the properties. For example,
QUESTION
I'm looking for the right approach to declare design-time ViewModel for an Avalonia window.
Some samples suggest
...ANSWER
Answered 2021-Dec-11 at 23:45Unable to find public constructor for type Demo.CloseNonModalDialog:Demo.CloseNonModalDialog.CurrentTimeDialogViewModel()
You can specify arguments via x:Arguments
XAML directive, see https://docs.microsoft.com/en-us/dotnet/desktop/xaml-services/xarguments-directive
That's an option, although I haven't yet found the right way to declare and reference the resource.
I'd suggest to declare DesignData
class and use x:Static
, it will give you way more flexibility. e. g.
QUESTION
I'm building a simple application using WPF and GalaSoft MvvmLight (5.4.1.1).
Everything works fine, I have a grid, and when a row is selected I enable/disable buttons that have actions assigned.
Sample button looks like that:
...ANSWER
Answered 2021-Dec-04 at 11:41Note: this is not related to MvvLight at all.
The WPF ButtonBase
class has hard-coded support for evaluating Command.CanExecute
to provide a value for the IsEnabled
property. See also IsEnabledCore
in the source code.
There is not such support for UserControl
, so you have to bind IsEnabled
yourself.
That said, you could - instead of defining a user control - use a Button control with custom control template.
QUESTION
I am currently working with WPF to create a simple minigame which requires pressing keys. I have done something similar with mouse clicking, yet I am struggling with keys. I have searched for a quite some time and I have found out that the most common way to work with keys is to define each key to its own event. But thats not my case and I want it to be able to fire it everytime any key is pressed. I have found out that this is possible to be done with MVVMLight and EventToCommand, but for some uknown reason to me, the KeyDown event will not fire (neighter KeyUp), but PreviewMouseLeftButtonDown will do.
xaml file:
...ANSWER
Answered 2021-Jul-06 at 13:16There is a PreviewKeyDown
event that you can try. The most common reason why it won't work with KeyDown
and MouseDown
is that the control already handles key presses and mouse interactions internally.
The PreviewKeyDown
event will only be fired when the control is focused so you'll also have to set the Focusable
property of the UserControl
to true
.
A better way to make sure that you always capture keypresses in a UserControl
would be to handle the keypress event of the parent window programmatically:
QUESTION
I'm trying to update my DataGrid
(name: dgLicenseholder, bound to an ObservableCollection
. I am using MVVMLight
) when I add new rows to the database.
Why isn't this working?
In my ViewModel
, I have a public DelegateCommand RefreshCommand {get; private set; }
and a method:
ANSWER
Answered 2021-Jun-21 at 14:15Okay there's much that I don't see here on how the database code is linked to your code but this might help:
QUESTION
I'm writing an app in WPF, trying to use the MVVM-design pattern (which is new to me).
I have a DataGrid
bound to an ObservableCollection
.
Delete the currently selected DataGrid-row using a 'Delete'-button. I've tried a plethora of forum-posts and videos to find a solution. The solution has probably stared me right in the face several times, but at this point I'm more confused than I was when I first started.
Any assistance would be appreciated.
ViewModel (updated with working code, thanks to EldHasp):
...ANSWER
Answered 2021-Jun-14 at 20:15You can use Prism. Intall package Prism.Core then Install-Package Microsoft.Xaml.Behaviors.Wpf -Version 1.1.31
packages in your project, in your xaml declare namespace as - xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
QUESTION
I'm new on WPF and I want to create a program using MVVM pattern (without using external library like MvvmLight). The application let the user to draw rectangles (and other shapes in future) inside canvas using mouse (similar to Windows Paint, just to be clear). The user could move/resize created rectangles using mouse interaction as well.
At this moment I implemented a basic version in which the user can add a rectangle (with random size/position) by clicking a button. This is the code of the MainWindow view which implement this behaviour:
...ANSWER
Answered 2021-May-24 at 18:04MVVM pattern is just a desired pattern to separate visual design from applicaton data structure, so when you say "MVVM pattern doesn't allow to put event handler (for mouse interaction) in view code-behind" maybe that is being too drastic. Try to stick to it for better designs but don't get too crazy at the beginning. Have a look at this page, it might be of interest.
WPF creates automatically the event handlers for you in the code behind, so that is the place for them. What you may want to do is to, instead of modifying your data directly inside your event handler, there will be a ViewModel whose methods will help you modify your data.
You can use the PreviewMouse(Up,Down,Move) events associated to the Canvas. It might be easier than trying to click on your shape, specially when several shapes may overlap. Obviously, if you have many shapes, there must be a way to know which shapes is going to be edited (manual selection through combobox, finding the closes shape to mouse click, etc)
From your design, one aspect that may give you some trouble is the fact that your viewModel manages 1 shape. It isn't wrong, but you need another VM layer that manages a collection of shapes. It can be done as another class or as a bunch of static methods in your MyRectViewModel
:
QUESTION
I'm troubleshooting a laundry list of exceptions that have recently begun to occur- We have a "single-use" service which we wrapped a bulk service around. The bulk service sets up all the variables required for each iteration, etc... The other variables are non-Entity/non-EF related. Roughly speaking:
...ANSWER
Answered 2021-Apr-30 at 18:05Thanks to @Gert Arnold's suggestion of disabling proxy creation, I was able to pinpoint that as the smoking gun which fixed the problem.
Working with proxies - EF 6 Microsoft Docs
I found that with proxy creation disabled, it was not necessary to override the SaveChanges()
method with the Transaction wrapper. That should match the default EF behavior anyway.
For completeness and for those finding themselves here in the future:
You can disable proxy creation in the initializer of your DbContext class as such:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install mvvmlight
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page