relaycommand

RelayCommand stops working after a while

拟墨画扇 提交于 2019-12-28 06:58:32
问题 I am facing some problems using GalaSoft's RelayCommand. I have a NextCommand property that works, but only several times. Afterwards, it stops working completely. You can try this out with the sample project: http://s000.tinyupload.com/?file_id=65828891881629261404 The behaviour is as follows: NextCommand : pops all items until the active index if there are less than 50 items left, pushes 1 new item marks new item as active BackCommand : moves the active index back by 1 position Steps to

MVVM Light RelayCommand Parameters

爷,独闯天下 提交于 2019-12-27 23:35:34
问题 I'm having an issue with passing a parameter to a relaycommand using the GalaSoft MVVM Light framework. I know that mvvm light's implementation of relaycommand doesn't use lambda parameters, so I did some research and found a way that people worked around it by doing something like this: public RelayCommand ProjMenuItem_Edit { get { if (_projmenuItem_Edit == null) { //This should work.... _projmenuItem_Edit = new RelayCommand(ProjEditNode); } return _projmenuItem_Edit; } } private void

EventToCommand issue in MVVM Light

无人久伴 提交于 2019-12-25 02:43:38
问题 I have the following visual tree for which I am trying to send a command through the EventToCommand. The visual is as follow : <Border Background="Gray" Grid.Row="0" Margin="2" VerticalAlignment="Bottom"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseDown"> <cmd:EventToCommand Command="{Binding ShowVideosCmd}" PassEventArgsToCommand="True" CommandParameter="{Binding Videos}"> </cmd:EventToCommand> </i:EventTrigger> </i:Interaction.Triggers> </Border> When clicking on the border

Execute a method on second control from the first control in WPF

早过忘川 提交于 2019-12-25 01:16:26
问题 My ViewControl has a method called ZoomIn() . How can I execute this method on this ViewControl by clicking Button control without going to code-behind. <controls:ViewControl/> <Button Content="Zoom In"/> ViewControl.xaml.cs: public void ZoomIn() { double actualWidth = m_child.ActualWidth; double actualHeight = m_child.ActualHeight; double x = (0.5 * actualWidth - Dx) / Scale; double y = (0.5 * actualHeight - Dy) / Scale; float startScale = Scale; Scale = Math.Min(Scale * ZoomFactor, ZoomMax)

Full implementation of Relay Command - can it be applied to all cases?

对着背影说爱祢 提交于 2019-12-25 00:07:32
问题 I'm looking at the full implementation of a Relay Command that can be found here I heard that the idea behind RelayCommand is to have a sort of "universal remote control" to use on all your commands. If that is the case, I have 2 issues with the implementation: 1) What happens if for certain controls I don't want to pass a parameter? Do I have to? Do I need to change my execute/can-execute functions accordingly to support these parameters? 2) What if I don't want to pass a CommandParameter in

How to find out which button I pressed?

耗尽温柔 提交于 2019-12-24 23:48:51
问题 Picture the notification-dropdown menu from Facebook. I want to implement something similar. When clicking 'Slet', it's supposed to delete that notification from the list. private void AddNotificationsToPanel(List<Notification> notifications, StackPanel panel) { panel.Children.Clear(); foreach (var notification in notifications) { //We want every message to have text, a delete button and a postpone button //So we need a nested stackpanel: var horizontalStackPanel = new StackPanel();

RelayCommand not firing on some computers

蹲街弑〆低调 提交于 2019-12-23 18:50:35
问题 First of all, this is my first post on SO, so be gentle ;) I have a very simple WPF application with a menu with two options and some buttons in different Views, most of these have data bindings to a Microsoft.TeamFoundation.MVVM.RelayCommand. When debugging on my computer it all works fine, when running the built exe it works fine, on my colleagues computer the built version works fine, but when testing on another computer at my office none of these RelayCommands will fire... XAML: //Menu

MVVM RelayCommand CanExecute

僤鯓⒐⒋嵵緔 提交于 2019-12-19 06:31:20
问题 I'm implementing an RelayCommand with an execute and an canExecute part. The RelayCommand works when it is without the canExecute part, however when I add the canExecute part, the command locks the button. The RelayCommand only checks whether or not the button can be executed as long as the CanExecute part is true. Once the canExecute part becomes false, the button can no longer be clicked, even if it is supposed to. How do I make sure that every time I click on the button it controls whether

Passing event args and sender to the RelayCommand

泄露秘密 提交于 2019-12-18 05:46:11
问题 How do you get event sender when using RelayCommand? 回答1: This is one of those pain-in-the-%¤# answers where I don't actually answer your question, but instead lecture you about what you should be doing differently. So, sorry about that. Here goes: If you find yourself in a position where you need to get at the sender object in your viewmodel, then you should probably do something different. By referencing, say, a Button or a ListBox in your viewmodel you have made that viewmodel aware of UI

Implementing “close window” command with MVVM

删除回忆录丶 提交于 2019-12-17 15:46:44
问题 So my first attempt did everything out of the code behind, and now I'm trying to refactor my code to use the MVVM pattern, following the guidance of the MVVM in the box information. I've created a viewmodel class to match my view class, and I'm moving the code out of the code behind into the viewmodel starting with the commands. My first snag is trying to implement a 'Close' button that closes the window if the data has not been modified. I've rigged up a CloseCommand to replace the 'onClick'