How in MVVM do you set a User Control Focus? Using Focusmanager.FocusElement={Binding ...} Has no affect.
Here is my XAML:
<DataTemplate DataType="{x:Type client:TelephoneNumberViewModel}">
<Grid FocusManager.FocusedElement="{Binding ElementName=TelephoneNumber}" Width="1024" Height="540">
<Grid.RowDefinitions>
...
I'm rebuilding Josh Smith's WPF CommandSink example and there are a few things that I don't understand about his databinding, especially about how datacontext is inherited when a view is contained in another view which is contained in a window which has a datacontext.
all databinding is declared in the XAML files, there is absolutely n...
Can anyone conjure from this code why the ItemsSource line would be getting a
Items collection must be empty before
using ItemsSource.
error? Most solutions I've found point to ill-composed XAML, e.g. an extra element etc. which I don't seem to have. When I take out
ItemsSource="{Binding Customers}"
it runs without an erro...
I have rebuilt Josh Smith's CommandSink example from scratch and my version runs without error except that my command buttons are grayed out. I assume this is because there is something somewhere not set correctly so that the commands never get set to CanExecute = true or at some point get set to CanExecute = false.
But since the databi...
I'm just getting started with the MVVM pattern in WPF and I decided that the most elegant way to structure my code was injecting the view-model in to the view's constructor.
This is all well and good, but ReSharper gives a warning in the XAML that my view doesn't have a default constructor. I'm assuming that this is so that I can constr...
I listened to this herding code podcast on MVC, MVP, MVVM yesterday and was struck by the idea of sending your whole ViewModel object to a validator which does nothing but validate all the fields in it and send it back.
has anyone implemented that type of validation pattern?
how did it look technically?
I am thinking of extending thi...
Currently there are a lot of variations on the MVVM design pattern but as I understand it the view is allowed to have dependencies on the viewmodel. A colleague of mine disagrees but he couldn't provide a satisfactory explanation.
E.g. my views contain a reference to their viewmodel. This is not needed for all views but it helps when co...
I am currently working on an application using WPF and MVVM. Now if i go to another user's machine and try to launch my app, i get an Exception due to missing ReflectionPermission at
BindToMethodInfo(Object, RuntimeMethodHandle, RuntimeTypeHandle, DelegateBindingFlags) in mscorlib.
Now my question is, what exactly requires the Reflectio...
I have a MVVM WPF application that basically wants to be a single line diagram designer for an electrical distribution network.
I have a canvas that must contains transformers, circuit breaker, lines and cables.
My big problem is the design... How can i start?
I think about a DesignerView, DesignerViewModel that contains an Observable...
Does anyone know how I can force CanExecute to get called on a custom command (Josh Smith's RelayCommand)?
Typically, CanExecute is called whenever interaction occurs on the UI. If I click something, my commands are updated.
I have a situation where the condition for CanExecute is getting turned on/off by a timer behind the scenes. Be...
I'm experimenting with MVVM for the first time and really like the separation of responsibilities. Of course any design pattern only solves many problems - not all. So I'm trying to figure out where to store application state and where to store application wide commands.
Lets say my application connects to a specific URL. I have a Conn...
I have the following model:
public class Model : INotifyPropertyChanged
{
public ObservableCollection<ViewElement> Elements { get; set; }
public ViewElement CurrentElement { get; set; }
}
And the following grid where the parent DataContext is the above model:
<dg:XamDataGrid DataSource="{Binding Path=Elements}" />
I want to ...
I'm planning a WPF application which will
be able to create dynamic data entry forms (meaning the form gets the fields to display, their order, etc. from data in the database, not from the XAML)
use the MVVM pattern if possible
Here is how I plan to go about it: in a Customer Data Entry View I would set the data context:
<UserContro...
Hello,
In my WPF application I have 2 Windows (both Windows have their own ViewModel):
Application's Main Window that displays list with bunch of words (bound to MainViewModel)
Dialog Window that allows users add new items to the list (bound to AddWordViewModel)
MainViewModel has Articles property of List(this collection is populat...
On my journey to learning MVVM I've established some basic understanding of WPF and the ViewModel pattern. I'm using the following abstraction when providing a list and am interested in a single selected item.
public ObservableCollection<OrderViewModel> Orders { get; private set; }
public ICollectionView OrdersView
{
get
{
...
The following RoutedCommand example works.
However, the handling for the button which executes the command is in the codebehind of the view. The way I understand MVVM, it should be in the ViewModel.
However, When I move the method to the ViewModel (and change it to public), I get the error "ManagedCustomersView does not contain a defin...
I've got a view which shows a listbox that is bound to GetAll():
<DockPanel>
<ListBox ItemsSource="{Binding GetAll}"
ItemTemplate="{StaticResource allCustomersDataTemplate}"
Style="{StaticResource allCustomersListBox}">
</ListBox>
</DockPanel>
GetAll() is an ObservableCollection property in my ViewMod...
I would like to pass a parameter defined in the XAML (View) of my application to the ViewModel class by using the RelayCommand. I followed Josh Smith's excellent article on MVVM and have implemented the following.
XAML Code
<Button
Command="{Binding Path=ACommandWithAParameter}"
CommandParameter="Orange"
...
I've been doing WPF applications with the MVVM pattern using Visual Studio, coding C# and XAML mostly by hand.
Now I've gotten up to speed with Expression Blend so that I can click together WPF applications quickly just using the GUI, which is very nice, much more control of the layout than fiddling around with all the XAML elements 80%...
Glenn Block and I have been working together on the ViewModel pattern. We’ve been trying to identify the biggest pain points associated with the pattern, with the goal of adding framework support to alleviate the pain.
Tonight, Glenn posted, “View Model” – the movie, cast your vote. We want to hear from you. Please post here (and vot...