delegatecommand

Is a DelegateCommand the same as an “Attached Behavior”?

时间秒杀一切 提交于 2019-12-21 20:07:52
问题 I have been using the DelegateCommand found in the MVVM Visual Studio template at CodePlex. This works very nicely for having Views be able to execute commands on their ViewModel. I read somewhere that in MVVM " attached behaviors " should be used. As far as I can tell, "attached behaviors" are the same type of pattern as DelegateCommand but are used by Silverlight since it does not have commands. Is this correct ? Or are "attached behaviors" something different in kind and worth learning in

Memory leak in WPF app due to DelegateCommand

自闭症网瘾萝莉.ら 提交于 2019-12-12 08:29:29
问题 I just finished desktop apps written in WPF and c# using MVVM pattern. In this app I used Delegate Command implementation to wrap the ICommands properties exposed in my ModelView. The problem is these DelegateCommands prevent my ModelView and View from being garbage collected after closing the view. So it stays larking until I terminate the whole application. I profile the application I find it’s all about delegatecommand that keeping the modelview in memory. How could I avoid this situation

How to make the CanExecute trigger properly using Prism 6

不羁的心 提交于 2019-12-07 15:38:27
I have a Model public class Irritant : BindableBase { private short _id; private string _name; private string _description; public short Id { get { return _id; } set { SetProperty(ref _id, value); } } public string Name { get { return _name; } set { SetProperty(ref _name, value); } } public string Description { get { return _description; } set { SetProperty(ref _description, value); } } public Irritant() { Id = 0; Name = ""; Description = ""; } } Then my ViewModel with two versions public class IrritantViewModel : BindableBase { private IrritantDb db = new IrritantDb(); //Version 1 - The Model

How do I pass the information from View to ViewModel with DelegateCommand?

本小妞迷上赌 提交于 2019-12-04 08:16:38
问题 In my View, I have a button. When the user clicks this button, I want to have the ViewModel save the context of the TextBlock in the database. <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top"> <TextBlock Text="{Binding FirstName}"/> <TextBox Text="Save this text to the database."/> <Button Content="Save" Command="{Binding SaveCommand}"/> </StackPanel> However, in my DelegateCommand in my ViewModel, the "Save()" method doesn't pass any arguments, so how do I get data from the

Memory leak in WPF app due to DelegateCommand

醉酒当歌 提交于 2019-12-04 03:59:31
I just finished desktop apps written in WPF and c# using MVVM pattern. In this app I used Delegate Command implementation to wrap the ICommands properties exposed in my ModelView. The problem is these DelegateCommands prevent my ModelView and View from being garbage collected after closing the view. So it stays larking until I terminate the whole application. I profile the application I find it’s all about delegatecommand that keeping the modelview in memory. How could I avoid this situation and is this in nature of mvvm pattern, or it’s about my implantation of the pattern?. Thanks. Edit:

How do I pass the information from View to ViewModel with DelegateCommand?

半城伤御伤魂 提交于 2019-12-02 22:14:25
In my View, I have a button. When the user clicks this button, I want to have the ViewModel save the context of the TextBlock in the database. <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top"> <TextBlock Text="{Binding FirstName}"/> <TextBox Text="Save this text to the database."/> <Button Content="Save" Command="{Binding SaveCommand}"/> </StackPanel> However, in my DelegateCommand in my ViewModel, the "Save()" method doesn't pass any arguments, so how do I get data from the view at that point? #region DelegateCommand: Save private DelegateCommand saveCommand; public ICommand

is there a uipickerview delegate method like scrollviewDidScroll?

∥☆過路亽.° 提交于 2019-11-28 12:29:30
I have a customized UIPickerview and I do not want to use a datepicker. I want to implement the feature where when a user scrolls down/up the hours, the AM/PM component switches while the hour is scrolling. This means that I need to switch it before pickerView didSelectRow is called. Is there a way to do this? Thanks Use following method, - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { // put your logic here. } Above method is from UIPickerViewDelegate, If user selects any element using pickerview, this method is automatically

When does the ui detach from commands?

混江龙づ霸主 提交于 2019-11-28 03:53:42
问题 I'm really scratching my head with this one. I have a mainwindow which opens a dialog. After the dialog closes, the CanExecute method on commands bound in the dialog are still executing. This is causing some serious problems in my application. Example: MainWindow has a button with a click handler. This is the click event handler: private void Button_Click(object sender, RoutedEventArgs e) { DialogWindow window = new DialogWindow(); window.ShowDialog(); } In the dialog I bind an items control

is there a uipickerview delegate method like scrollviewDidScroll?

你。 提交于 2019-11-27 07:04:12
问题 I have a customized UIPickerview and I do not want to use a datepicker. I want to implement the feature where when a user scrolls down/up the hours, the AM/PM component switches while the hour is scrolling. This means that I need to switch it before pickerView didSelectRow is called. Is there a way to do this? Thanks 回答1: Use following method, - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { // put your logic here. } Above method is