mvvm

MVVM - How to create columns at runtime for a xamdatagrid?

I have to create a XamDataGrid that shows a dynamic amount of columns for a time frame x to y. Therefore I dont know how many years a user would select to have these columns created upfront. Now usualy within MVVM you would just populate the data through as many Properties as you would need Columns within your XamDataGrid and the latter...

canceling remove action - NotifyCollectionChangedAction

I am using the following code in my viewmodel to delete items out of a collection: UnitMeasureCollection.CollectionChanged += new NotifyCollectionChangedEventHandler(ListOfUnitMeasureCollectionChanged); void ListOfUnitMeasureCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChan...

Moving ListBoxItems around a Canvas?

Hello all. I'm working on dragging objects around a Canvas, which are encapsulated in ListBoxItems -- the effect being to create a simple pseudo desktop. I have a ListBox with a Canvas as the ItemsPanelTempalte, so that the ListBoxItems can appear anywhere on screen: <ListBox ItemsSource="{Binding Windows}"> <ListBox.ItemsPanel> ...

I don't test my model, MVC for WPF

Yesterday I have a talk with my ex-boss, he was a great programmer but the old style B-) me: boss have you heard about Presentation Model AKA MVVM? him: yes, but I don't like it me: why? it is already have a worshiper out there, him: not necessary to me.. you know dude, i don't want to DRY my domain in Model and View Model, and somet...

WPF Image Source binding with StringFormat

Hello, I'm new to WPF and MVVM (started this week experimenting with it) and trying to bind image resources at runtime. The items I'm trying to display contain an enumerate property that indicates the type or state of the item: public class TraceEvent { /// <summary> /// Gets or sets the type of the event. /// </summary> ...

WPF: Proper configuration for Window with a child UserControl (MVVM)

I am trying to properly accomplish the following. I have a UserControl (ProgramView). It has a viewmodel (ProgramViewViewModel). ProgramView is consumed as a child control within a Window (ProgramWindow). ProgramWindow has a public property ProgramId, so the consumer of the window can specify the desired Program (data entity) to show. Pr...

MVVM-Pattern for a Diagraming Application with WPF - Convert enum to xxxViewModel

Hi everybody, I'm trying to apply the MVVM design pattern to a diagramming application. In this application there are different items (for example a rectangle, a circle,...). I would like to save the item type as an enum in my model. In my modelview I made a class for every item type (rectangleViewMode, circleViewMode,...). On my view...

Images in a List in WPF MVVM

I have a question regarding how to best accomplish something in WPF MVVM. I have in my ViewModel a series of integers. For the sake of example, lets call them: public int Yellow { get;set; } public int Red { get;set; } public int Green { get;set; } I also have some small images that are very simple: A Red circle, a Yell...

How to get Rx Observable event stream inside MVVM ViewModel

I was just reading Rx HOL NET. Upon finding (example uses Windows Forms): var moves = Observable.FromEvent<MouseEventArgs>(frm, "MouseMove"); I wonder how can I instantiate and pass the reference to moves to ViewModel in some WPF MVVM setup? In my understanding it does make sense to try and filter this stream of data inside ViewModel....

wpf creating dynamic clickable "grid"

I'm not really sure how to go about my problem. Not looking for complete code just help with in which direction i should go. Since its MVVM I don't want any codebehind... if possible... From the db i get the size of the "grid" i should create, for example 2x3. Now i wish to place an "item" in this grid that takes up one or more spots. ...

SilverLight - A way to find which property caused the update to the model

Hi, I've got an MV-VM based SL dialog that seems to fire up a property in the model which I cannot find where it's been triggered from. When debugged the Stack Trace show it as external code. I feel it is the control itself causing a couple of updates for 1 click to the model with wrong data but not extactly sure why since the control (r...

Is there a way to start a WPF application without StartUpUri that doesn't break something else?

I've been trying for hours to get to the point where I can start a WPF application and have full control. I want to be able to create a ViewModel, create a View (Window), set the data context of the View to be the ViewModel, then show the View. I've tried lots of methods, the most promising being to change the App.xaml to be a page and ...

Using PasswordBox with WPF - MVVM

I've read several articles about how to use Attached Properties to bind to the value of a PasswordBox in WPF. However, every article also references the .NET documentation which explains why the PasswordBox was not made bindable in the first place. I do not consider myself a security expert by any means, but I figure that someone at Mi...

enabling disabling buton on checkbox check/uncheck wpf mvvm

Hi, I have list of checkboxes on a window specifying some items to be ordered. I neeed to first disable the Order button when the windows loads and enable it after selecting/check some items(checkboxes) and vice versa. I have bind the IsChecked property of the checkbox. Kindly Suggest. Thanks. Edit Import from OP comment:- I have o...

xamdatagrid, blend interaction triggers and control template with MVVM pattern

Hi, i have problem with control template of infragistics xamdatagid in using with blend interaction triggers. Template is adding delete button style and edit button style for each row of xamdatagrid. When i am trying to set interaction trigger on event (MouseLeftButtonDown) and bind it to my command property in corresponding ViewModel, s...

Calling or sending values from MainViewModel to other ViewModels mvvm mvvm light

Hi, We are using mvvm light framework to build our application. In our ViewModel folder, we have number of Viewmodel like orderSupplyViewModel,HouseholdSupplyViewModel etc files as per the different functionality of the application. We have included all these viewModels in the MainViewModel by making the MainViewModel as partial class. ...

WPF: KeyBinding for Tab, Swallows Tab and Doesn't Pass It Along

I've got a textbox where I have this: <KeyBinding Command="{Binding MyCommand}" Key="Tab"/> Problem is it swallows the Tab and doesn't tab to the next control. How can I trap the Tab for the textbox and still preserve tabbing to the next control in the tab order? Edit: I'm also using MVVM and MyCommand is in the ViewModel code, so that...

WPF & MVVM: Save ScrollViewer Postion And Set When Reloading

I've got a ScrollViewer for a StackPannel. The users want the save the position of the ScrollViewer so when the application is re-loaded with their data the StackPannel will show the items they were viewing before. It has nothing to do with which items were selected, if any, merely the potion of the ScrollViewer in relation to the StackP...

Is it ok to use ReportProgress of a BackgroundWorker to do other stuff?

I'm writing a WPF app using an MVVM approach. In my ViewModel, I have an ObservableCollection. Periodically, my app needs to check for new messages, and, if there are any, it needs to add them to the ObservableCollection. If I try to add to the ObservableCollection in the DoWork, it doesn't work because of thread synchronization issue...

WPF MVVM-Accessing the properties of a control of View in the View Model

I am using different toggle buttons and buttons in the view. I need to use the IsEnabled and IsChecked property of the toggleButtons in the view Model to diable some buttons and toggle buttons based on some conditions. Suggest me any methods to access any properties of a control in the view to the view model. ...