mvvm-light

How to make the binding happen from the ViewModel

落花浮王杯 提交于 2019-12-25 05:08:18
问题 I'm trying to capture the Enter key being pressed on a text box, so that I can kick off an update to the server. It's not working, and so I've reduced the problem to it's simplist elemetns. In this example, it seems that the binding is not happening per keystroke, but at sometime later. I need to the binding to be completed by the time the enter key is pressed. Consider the following XAML and function from the VM. Here's the XAML of the textbox <TextBox Text="{Binding TextValue, Mode=TwoWay}"

Cascading Combobox in DataGrid using DataTemplate Cross-Cell Binding

梦想的初衷 提交于 2019-12-25 04:47:09
问题 If I place my cascading comboboxes inside the same DataTemplate in a WPF DataGrid cell - the binding works properly ( via ElementName ). However, from a UI perspective I want my comboboxes to physically reside in different cells, not the same datagrid cell. How do you make cross-cell binding work ( between DataTemplates ) using DataGridTemplateColumns ? It seems the issue is that the second comboboxes' ItemsSource cannot find the ElementName for binding when the comboboxes exist in different

DataBinding with MVVM Light tool kit

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-25 04:19:34
问题 I get some trouble with the binding using MVVM toolkit and would likr to knwo some advise if I do things correctly. First of all I have the View Model Locator which is defined as follow : public class ViewModelLocator { private static MainViewModel _main; private static ProductViewModel _product; /// <summary> /// Initializes a new instance of the ViewModelLocator class. /// </summary> public ViewModelLocator() { ////if (ViewModelBase.IsInDesignModeStatic) ////{ //// // Create design time

ListBox Navigation Page MVVM Light in Windows Phone

大城市里の小女人 提交于 2019-12-25 03:40:14
问题 I am Building location based services Windows Phone App and this is my first app. I have a difficulty in page navigation by using MVVM Light. I am following Jesse Liberty Tutorial and so far, when I click the item on my ListBox in the FirstPage, it can navigate to SecondPage. What I want to do is, what user select from ListBox in the FirstPage bind with my ListPicker in the SecondPage . So user can easily change what they want to search from SecondPage . MainPage.xaml <ListBox x:Name=

Mvvm - Cancel changes in Wpf Listbox, vb.net

喜夏-厌秋 提交于 2019-12-25 03:35:17
问题 I have a wpv/mvvm-light/vb.net application with a master/detail view. In this view there is a listbox of clients and a detail view of the client's details where they user can view and edit the customers. I wanted to add a function where users would be prompted to save changes when a new client is selected in the listbox. If the user chooses yes from the messagebox then save changes and if no then discard changes and return previous selected item back to its original value. I have this all

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

Register all viewmodel and services in ViewModelLocator

痴心易碎 提交于 2019-12-25 02:29:21
问题 I am developing a new MVVM light Wpf application.I have 25 View and ViewModels and 25 DataService Interface and its implementations (One implementation for Design time Data service and one for realtime dataservice). For Eg, Here is a my DataService Interface for my SupplierViewModel: interface ISupplierDataService { ObservableCollection<Tbl_Supplier> GetAllSuppliers(); int GetSupplierCount(string supplierNameMatch); } and Here is its implementation for design time : class

Databinding a command to Context Menu with an Observable Collection

感情迁移 提交于 2019-12-25 02:25:51
问题 I have a Context menu with some options. One of the options is an Observable collection and I am having issues binding my commands in my view model to them. I have seen many different ways to fix this issue, but none have worked because they do not specifically relate to my problem. Here is my code first: XAML: <ListView ItemsSource="{Binding ListViewItems}" SelectionMode="Single"> <ListView.ContextMenu> <ContextMenu DataContext="{Binding Path=PlacementTarget, RelativeSource={RelativeSource

How to close a UserControl View in mvvm-light?

▼魔方 西西 提交于 2019-12-25 01:03:20
问题 I've craeted a sample with mainView and 2 other views (usercontrols). I've placed a button "close" on the child view and i want to close that view. there is a command attached to that button, and when close is pressed i ask the ViewModelLocator to clean it. BUt- the view still being displayed.. What i'm doing wrong? How can i close a userControl view with mvvm-light? private RelayCommand _closeCommand; public RelayCommand CloseCommand { get { if (_closeCommand == null) { _closeCommand = new

ListBox.ContextMenu Get Selected Item via Command [duplicate]

馋奶兔 提交于 2019-12-24 15:52:06
问题 This question already has answers here : Pass command parameter from the xaml (2 answers) Closed 4 years ago . I have this View: <StackPanel> <StackPanel.DataContext> <local:MainViewModel /> </StackPanel.DataContext> <ListView ItemsSource="{Binding Persons}" x:Name="xamlPersonList"> <ListBox.ContextMenu> <ContextMenu> <MenuItem Header="EMail" Command="{Binding WriteMailCommand}" CommandParameter="{Binding ElementName=xamlPersonList,Path=SelectedItem}" /> </ContextMenu> </ListBox.ContextMenu>