Hi,
I am implementing the Model-View-ViewModel (MVVM) pattern in one of the forms of my SL2 appication using INotifyPropertyChanged interface and TwoWay Databinding.
However I feel that due to this approach, my form behaves slightly sluggishly.
I just wanted to know whether using this approach is there any performance hit in such SL...
Hi All
I have an application where I'm displaying UserControls in a GroupBox. To display the controls, I'm binding to a property in the ViewModel of the main form, which returns a ViewModel to be displayed. I've got DataTemplates set up so that the form automatically knows which UserControl/View to use to display each ViewModel.
When...
I am building an wpf app using MVVM. I have viewModels the employ lazy loading like below:
public class AssignmentsViewModel
{
List<AssignmentViewModel> _Assignments;
public List<AssignmentViewModel> Assignments
{
get
{
if (_Assignments == null)
_Assignments = new List<AssignmentV...
I have been trying to come up with a better localization approach than LocBaml (wich sucks). And I though I could use something like {DynamicResource {x:Static LocalizableTexts.OpenTextKey}} (dynamicresource because my language could change at runtime). The only question is? How do I correctly create LocalizableTexts.OpenTextKey ? Is the...
Let's say I have a View that is bound to ViewModel A which has an observable collection Customers.
An advantage of this MVVM pattern is that I can also bind the View to ViewModel B which fills it with different data.
But what if in my View converter Converters to display my customers, e.g. I have a "ContractToCustomerConverter" that ac...
Over at the StackOverflow question How can WPF Converters be used in an MVVM pattern? I've learned that Value Converters should not be used in the MVVM pattern since the functionality of a Value Converter should be handled by the ViewModel itself.
This makes sense.
But I remember reading that you should not expose XAML elements to the ...
Users love animations. See the iphone for a good example :) Everything a user does in the iphone kicks off an animation.
Enter MVVM and Commanding (I'm thinking about Silverlight 2 specifically). A user action triggers an event via Commanding, and we're sitting in the ViewModel thinking about how to trigger a nice animation for the u...
Interesting problem related to firing commands from context menu items...
I want to fire a command to insert a row in my control, InsertRowCmd. This command needs to know where to insert the row.
I could use Mouse.GetPosition(), but that would get me the position of the mouse currently, which would be over the menu item. I want to get...
In the code below, when user selects Customer in the combobox, the customer's name is displayed in a textbox. I fill the Combox box with an ObservableCollection property on my ViewModel but how do I handle the SelectedItem event in my ViewModel?
It's easy to implement this with code-behind as shown below, but how do I do this with the ...
I'm new to both WPF and MVVM. I searched for a good way to dynamically create menus in the MVVM partern and, not finding anything to my liking, rolled my own solution. It works, but for some reason the Foreground (text) color of the menus is sometimes (just sometimes) not correct.
I was going to include a picture to demonstrate my pro...
In my View I have a slider and a combobox.
When I change the slider, I want the combobox to change.
When I change the combobox, I want the slider to change.
I can udpate one or the other, but if I try to update both I get a StackOverflow error since one property keeps updating the other in an infinite loop.
I've tried putting in a Re...
So let's say I have an MVVM application and I want the user to fill out a TextBox and while he is filling it out, I want to check to see if he has typed in the last name of a customer yet.
Here is how I get my ViewModel to know when the user has changed the item in the ComboBox:
<ComboBox
ItemsSource="{Binding Customers}"
Ite...
In MVVM, every View has a ViewModel. A View I understand to be a Window, Page or UserControl to which you can attach a ViewModel from which the view gets its data.
But a DataTemplate can also render a ViewModel's data.
So I understand a DataTemplate to be another "View", but there seem to be differences, e.g. Windows, Pages, and UserCo...
I want my TextBox to have a red background if the ViewModel property = "invalid". What do I have to change so this works?
This version tells me that Background does not have a qualifying type name.
<TextBox
Width="200"
Text="{Binding FieldEmail, UpdateSourceTrigger=PropertyChanged}">
<TextBox.Triggers>
<DataTrigger ...
When you use the MVVM Visual Studio Template, then your ViewModels are bound to your Views' DataContexts in the App.xaml.cs something like this:
MainView mainView = new MainView();
mainView.DataContext = new MainViewModel();
mainView.Show();
And if you use Composite Application Library, then you have your Views and ViewModels being bo...
I want to build a simple application with the MVVM pattern.
This application will have two main parts:
menu on top
content below
The navigation will be simple:
each menu item (e.g. "Manage Customers" or "View Reports") will fill the content area with a new page that has some particular functionality
I have done this before with ...
I've got this menu bound to an ObservableCollection called MainMenuPageItems, in which there are objects that have a Title property:
<Menu DockPanel.Dock="Top">
<MenuItem Header="_File">
<MenuItem Command="{Binding ExitCommand}" Header="E_xit" InputGestureText="Ctrl-X" />
</MenuItem>
<MenuItem Header="Code _Generatio...
I'm using the RelayCommand in my app. It's great for putting the code in the viewmodel, but how do I bind keystrokes to my command?
RoutedUICommand has its InputGestures property, which makes the command automatically be invoked when I press the keystroke. (As an added bonus, it even makes the keystroke display in the MenuItem.) Unfortu...
I like the MVVM idea of a RelayCommand that's exposed by the ViewModel. That's nice and elegant, for operations that can be done with no further user input. Simple. Testable.
However, not all operations are UI-less. Some require confirmation ("Are you sure you want to delete?"). Others require more information yet. Opening a file might ...
Hi,
I am developing a Silverlight 3 application, in which I have a boolean property in my Model class (using MVVM approach) that's bound to "IsEnabled" target property of two buttons. I need to find out which button invoked this boolean property when I raise the PropertyChanged event (i.e. during databinding).
Is there something in the...