FAQ Database Discussion Community


Call controls inside view(xaml file) in viewmodel

wpf,vb.net,mvvm
I want to call controls inside view like button and item template inside viewmodel. Please tell how can I do that. My view contains following <ItemsControl Name="cDetails" Width="395" ItemTemplate="{DynamicResource Test}" ItemsSource="{Binding ViewModels}" Visibility="{Binding IsLoaded, Converter={StaticResource visibilityConverter}}"> <Button Name="btnComplete" Grid.Column="1" HorizontalAlignment="Center" Command="{Binding AuditCommand}" CommandParameter="1"> Complete </Button> Please tell how can I...

Property not change on two way binding mode with dependency property

c#,wpf,mvvm,dependency-properties
I have the following dependency property: public bool UndoZoom { get { return (bool)GetValue(UndoZoomProperty); } set { SetValue(UndoZoomProperty, value); } } // Using a DependencyProperty as the backing store for UndoZoom. This enables animation, styling, binding, etc... public static readonly DependencyProperty UndoZoomProperty = DependencyProperty.Register("UndoZoom", typeof(bool), typeof(ZoomBehavior), new PropertyMetadata(false, new PropertyChangedCallback(OnUndoZoomChanged)));...

Telerik PdfViewer - Binding to a PDF source

c#,wpf,mvvm,telerik
I've tried the samples on telerik's website as well, and to no avail. So I have this code: public ICommand EmailPopUpCmd { get; set; } private void EmailPopUp(object sender) { //ToDo: pdf viewer pop up selectedDataRow = (DataRow)sender; var window = new Window(); window.Content = new EmailView() { DataContext =...

ItemsSource bind to collection stays empty

c#,wpf,xaml,mvvm
I have a class YouTubeVideo which contains some variables, which I would like to show on the UI. Therefore I created a custom control which shows all the data of the class. There are more than one instances of the class, so I would like to use an ItemsControl to...

textbox styling for all the forms in the project

wpf,xaml,mvvm
Here is the code for the Textbox in one of my form(window1.xaml) here i have applied Textbox.style for the textbox, My requirement is i want to apply this same style for all the textboxes in my project all windows(window2.xaml,window3.xaml,.........) <TextBox Grid.Column="0" MaxLength="1000" x:Name="txtQuestionDesc" HorizontalAlignment="Stretch" TextWrapping="Wrap" AcceptsReturn="True" Grid.Row="1" Margin="5,0,0,5" Height="100" Text="{Binding...

Why use commands in MVVM

.net,mvvm,icommand
I'm actually learning MVVM pattern. I can't understand one thing about commands. Why use them? Why don't just use a function (in the View) which call a ViewModel's function? What commands provide us? Apparently they are widely used, but i can't find why....

How can I bind Pushpin location in WPF using MVVM?

wpf,mvvm,windows-8.1,bing-maps-api
I'm developing a Desktop application that uses Bing maps and MVVM. In the application, a user adds a Pushpin in the map by double clicking on it, the Pushpin location gets saved in an Event class and the Event class is sent through a WCF Service. I would like to...

Update DataGrid cell if other cell changes

c#,wpf,mvvm,datagrid
I have a View that displays a Part. All parts contain a list of identifiers. In my View I display Part Properties and a DataGrid with all the Identifiers of that part. Now if I change a value of an identifier, I want another value update to the default. But...

How to set data context of ViewModela View's xaml?

c#,listview,design-patterns,mvvm,windows-universal
I'm trying to set the data context of a View to the list contained in it's ViewModel. But when I've tested the current set up, it seems the data context between the ViewModel and View is set incorrectly. To debug this issue I set up a message box in the...

MVVM How to set datacontext when viewmodel uses async

c#,asynchronous,mvvm,windows-phone-8.1
After hours of searching I am still without answer to this question. I have read this nice writing about async MVVM and made my viewmodel to use factory method. public class MainViewModel { public MainViewModel() { } private async Task InitializeAsync() { await DoSomethingAsync(); } public static async Task<MainViewModel> CreateAsync()...

Change Entities name in WPF MVVM scaffolding from DevExpress

c#,wpf,entity-framework,mvvm,devexpress
How to change entities name for UserControl Header? I am create CodeFirst EF6 model and use scaffolding wizard from DevExpress. I change Entities name in NavBarControl in ViewModel for CollectionView, but how to change entites name for new opened View? Main problem picture...

Bind IsEnable property of button located inside data grid to variable

wpf,mvvm
I want to bind IsEnable property of button to variable. Button is added inside data grid. Data Grid is located inside user control. Below code is not working. <DataGridTemplateColumn Header="Start" > <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button x:Name="Start_Button" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type UserControl}},Path=DataContext}" IsEnabled="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type...

How to apply a style of a Button dynamically in WP 8.1?

c#,.net,xaml,mvvm,windows-phone-8.1
I have one WP 8.1 apps. I am following a complete MVVM design pattern. In the XAML code <Grid> <Canvas x:Name="gameCanvas" Width="{Binding CanvasWidth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> <ItemsControl ItemsSource="{Binding Path=ButtonItems, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> <ItemsControl.ItemTemplate> <DataTemplate x:Name="Dta"> <Button x:Name="newsItemBtn" Height="{Binding Height}" Width="{Binding Width}" Style="{StaticResource ButtonStyle2}" Content="{Binding...

How do I make EF Code First Data Annotations work with MVVM?

c#,entity-framework,mvvm
This is probably an incredibly stupid question. In MVVM tutorials, a model would look something like this: public class Case : ObservableObject { private int caseID; public int CaseID { get { return _caseID; } set { if (value != _caseID) { _caseID = value; OnPropertyChanged("CaseID"); } } } In...

ContextMenu too-wide WPF

wpf,mvvm,contextmenu
I have built a ContextMenu dynamically using MVVM. The problem is : the content of MenuItems is all in right side ==> too wide ContextMenu. Do you have any ideea which is the problem? Thanks Here is the code in XAML: <TreeView.ContextMenu> <ContextMenu Name="RightClickMenu" ItemsSource="{Binding Path=SelectedItem.MenuItemsList}"> <ContextMenu.ItemTemplate > <DataTemplate> <!--...

How to make Kendo Datasource request from server side API call using Kendo MVVM and c#?

c#,asp.net,mvvm,kendo-grid,kendo-asp.net-mvc
I am using HTML page as a front end and i have to transfer a row of json data to database, how should i transfer a row full of values as a parameters to server side function or request datasource from server side to populate entities? Here is my html...

Ext JS 5 Data Binding Combobox

extjs,mvvm,binding,extjs5
I have an Ext JS 5.0.1 application that I am working on. I have a simple window with a grid and a form. I have the grid bound to my store and when a row is selected, all the textfields in the form bind, but I also have a combobox...

Button doesn't work in FlipView with DataTemplates - WinRT

c#,wpf,xaml,mvvm,windows-runtime
I'm using Flipview and a DataTemplateSelector to determine at runtime which DataTemplate to apply to show items in my control. I have two DataTemplate's, one is static and the second can be used by a undetermined number of items. The problem is that the button does nothing. I've used a...

Dynamic editing Content

c#,wpf,mvvm,user-controls,observablecollection
I have a MVVM application using 3 usercontrols as content in multiple pages (pages are also usercontrols) with some additional static content. For example: Page1.xaml <StackPanel x:Name="pnlMain" Orientation="Vertical"> <TextBlock FontWeight="Bold" Text="Title 1" /> <local:UserControl1 /> <TextBlock FontWeight="Bold" Text="Title 2" /> <local:UserControl2 /> <local:UserControl2 /> </StackPanel> Page2.xaml <StackPanel x:Name="pnlMain" Orientation="Vertical"> <TextBlock...

Bind Multibinding Textbox in WPF MVVM

wpf,mvvm
I have 3 TextBoxes bind with my class(Transaction) properties like this <TextBox Text="{Binding Path=Transaction.Bills100,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Name="bills100" Grid.Column="2" Grid.Row="1" Margin="7"></TextBox> <TextBox Text="{Binding Path=Transaction.Bill50,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Name="bills50" Grid.Column="2" Grid.Row="2" Margin="7"></TextBox> <TextBox Text="{Binding Path=Transaction.Bill20,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"...

Filtering ObservableCollection with ICollectionView

c#,wpf,xaml,mvvm,data-binding
I have ObservableCollection binded to dataGrid and now I want to filter the presented data I see that I need to use ICollectionView but I am not sure how to add ICollectionView with my MVVM pattern. My code simplified looks following: public class MainViewModel : ViewModelBase , IBarcodeHandler { public...

How to display the error message for DataAnnotations

c#,entity-framework,mvvm,data-annotations,ef-database-first
I've spent the last hour or so googling for an answer to this, but nearly every result is either in ASP.NET or talks about Code First approaches which are useless to me. I've basically got database-first entity framework POCO objects which I'm providing validation for using IDataErrorInfo. Now this works...

Event Names for converting into MVVM pattern

wpf,vb.net,mvvm
I am converting silverlight code into MVVM pattern. I want to know event name like for "closing event" I am using code. <i:Interaction.Triggers> <i:EventTrigger EventName="Closing"> <i:InvokeCommandAction Command="{Binding OnClose}" /> </i:EventTrigger> </i:Interaction.Triggers> I want to perform similar task on following events. IsVisibleChanged Windows_SizeChanged webBrowser1_Unloaded DataContextChanged LoadingProgress_Loaded Please Help....

How to bind and refresh UserControl binding in WPF?

c#,wpf,mvvm,data-binding,user-controls
I'm trying to do a simple OneWay binding for a user control, but I honestly don't understand why some parts aren't working. To be simple, I created a WPF standard UserControl with some dependency properties. In my main window, I hide/display the UserControl depending of some events, and I bound...

Is it ever appropriate to add an ICommand to your domain model objects?

mvvm
I'm working on applying the MVVM pattern (and learning it in the process) for a Windows Store application. Right now I am leaning towards having a 1:1 correspondence between View and ViewModel, where multiple ViewModels have a dependency on the same underlying Model. For example, suppose I have an entity...

UI Control Visibility Before Command Invocation?

c#,wpf,mvvm,mahapps.metro
I have a button command which sends several emails and therefore takes a few seconds for the method to execute. I want to show a progress ring Mahapps.Metro & disable the view whilst this method is executing. Here's my ProgressRing in my view: <Controls:ProgressRing IsActive="True" Visibility="{Binding IsProgressRingVisible, UpdateSourceTrigger=PropertyChanged}" /> ViewModel...

How to make ListView update at background and not freez UI when ItemsSource updated?

c#,wpf,listview,mvvm,binding
I have a ListView: <ListView ItemsSource="{Binding Students, IsAsync=True}"> <ListView.View> <GridView> <!--Some view things --> </GridView> </ListView.View> </ListView> and this is Students in my ViewModel: public ICollection<Student> Students { get { return _students; } set { _students = value; OnPropertyChanged(() => this.Students); } } I'm updating Students in some tasks like...

Building an Application using MVVM

wpf,vb.net,mvvm
I need some help to architect an MVVM application. This time I want to do it in the right way. My View is bound to the ViewModel which is bound to the Model. No problem there. Displaying data is not the problem, updating it is my problem. So when the...

Interfacing with xaml viewmodel

c#,wpf,xaml,mvvm
Im trying to create a simple program where you can add a car to a list and view the make model and year. In my xaml mainwindow I have 3 text boxes to collect the information from the user: <TextBox Text="{Binding NewCar.Model}"/> <TextBox Text="{Binding NewCar.Make}"/> <TextBox Text="{Binding NewCar.Year}"/> Then the...

How to bind a datagrid row with text boxes in wpf mvvm

wpf,mvvm,binding,datagrid
I have a DataGrid which contains some Product details , i need to load the product details into some textboxes when i double click on a particular product in the datagrid. Thanks in advance....

Binding property of usercontrol to data

c#,xaml,mvvm,binding,winrt-xaml
I'm not sure of the correct terminology to use. I created a Windows Store app about a year ago and the main page was created by Visual Studio and I never changed it much. It uses a view model that works fine but I don't know enough to fix problems....

WPF ViewModel GC

c#,wpf,mvvm,memory-leaks,garbage-collection
I have a ViewModel that on receiving an event from a Model, shows a dialog to the user by newing up the dialog's ViewModel and passing it to the dialog for data binding, i.e., public class MainViewModel { ... private void OnModelRaisedEvent(object sender, EventArgs e) { DialogViewModel dialogViewModel = new...

MVVM pattern necessarily needs a database? [closed]

c#,.net,mvvm
MVVM pattern necessarily needs a database? Because, all crud examples that I found do not use a database, they all do the CRUD inside the code, with list's and obsservableCollection's. Thanks

In a ComboBox, how can I format the names in the dropdown using XAML?

c#,wpf,xaml,mvvm
I am using WPF + MVVM. If I have a ComboBox, normally the names listed in the Dropdown are is defined by the .ToString() overload on the contents of the ObservableCollection. Is there a way to control the names in the Dropdown list using XAML instead of the .ToString() overload?...

TreeView with inherited types

c#,wpf,xaml,mvvm,treeview
I want to display a TreeView containing elements implementing an interface. This interface is implemented by two main classes, which are the ones I want to display. The schema is something like: IElement Container : IElement ->public IEnumerable<IElement> Elements {get; set;} Element : IElement So basically, this TreeView must be...

Observing mouse event in ViewModel Swift (Reactive Cocoa 3.0)

swift,mvvm,reactive-cocoa,reactive-cocoa-3
I'm trying to make a connection between my view and my viewModel using RAC 3.0. (Been reading Colin Eberhardt great tutorials on this) I want to subscribe to a Signal that fires every time func mouseUp(theEvent: NSEvent) is called. I.e. func mouseUp(theEvent:NSEvent){ //create some signal or pass a variable here...

How to constantly delay the execution of a method

c#,wpf,mvvm
I have a ICollectionVIew named 'CompanyView'. I also have a Filter for it called 'CompanyFilter'. And a Textbox bound to a 'SearchCompanyTitle' property. As I type in a databound textbox, 'CompanyFilter' gets fired with every letter and the 'CompanyView' gets filtered to show relevant results. That works fine. Unfortunately the...

c# MVVM update Datagrid after combobox selection

c#,wpf,mvvm,data-binding,datagrid
I am creating a small wpf programme which filters a dataset by date. It will eventually group and sum the data, but at the moment I am just trying to display the data rows. I want a window with a ComboBoxat the top with possible dates to select and a...

Update bindings

c#,wpf,xaml,mvvm
I have a grid with squares (tiles). Each of them has a color. Player1 = black, Player2 = white, no player = Transparant and if their is a square with no player but it is a valid move, the square has the color SkyBlue. I have the code on pastebin...

RaiseCanExecuteChanged is not recognized even with the right directive

c#,wpf,mvvm,icommand
I'm still learning mvvm and coding with c#, but I got stuck on a problem which I don't know how to work around it. My project doesn't seem to recognize RaiseCanExecuteChanged even when I'm using System.Windows.Input; I use MVVM Light and in NET4.5 The error I keep getting is `System.Windows.Input.ICommand`...

WPF bindings do not pick up any changes

c#,wpf,xaml,mvvm,inotifypropertychanged
In my WPF application, I have some properties which I have bound to the XAML counterpart, but for some reason do not get set whenever their values change. I have implemented the INotifyPropertyChanged interface as well as set my DataContext for this View too, and it is still not picking...

Update bindings from other bindings using MVVM in WPF

c#,wpf,xaml,mvvm,binding
Does anyone have any suggestions of how to fix my problem?? I have a datagrid binded to a collection of ModelCheckoutRecord objects (ListModelCheckoutRecords). I am binding the selected item to a ModelCheckoutRecord (SelectedItemModelCheckoutRecord). In the binding for the selected item I want to update the visibility binding for another datagrid...

MVVM: close auth window and open another

c#,wpf,mvvm
guys. What i need to do if i want auth user, close auth- window and open new window which will contain some information? <Window x:Class="VSgonnadie.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:nspase="clr-namespace:VSgonnadie" Title="Auth" Height="236.564" Width="166.922"> <Window.DataContext> <nspase:ViewModel /> </Window.DataContext> <Grid Margin="0,0,2,1"> <Button x:Name="AuthButton"...

WPF image stop repainting

c#,wpf,mvvm,graphics
Using WPF and MVVM I'm trying to display camera images into a Image. Each frame camera got, a callback is called : Viewmodel public void OnNewFrame(object sender, EventArgs e) { Camera camera = sender as MyCamera; camera.ToBitmap(out _bmpImage); RaisePropertyChanged("BMPImage"); } Each frame, I update the variable _bmpImage : ViewModel private...

ViewModel Called on Navigation Back Prism MVVM Windows Phone 8.1 C#

c#,xaml,mvvm,windows-phone-8.1,prism
I'm working on an application and everything works fine but when I go back to the previous page the View Model is called so it will not maintain the old data. I use this line to call My View Model in XAML. prismmvvm:ViewModelLocator.AutoWireViewModel="true" So my question is: How do I...

RadioButtons binding on Windows Phone 8.1

c#,xaml,mvvm,radio-button,windows-phone-8.1
I have some problem with binding my RadioButton property IsChecked. I have two RadioButton's on the grid, which Visibility binded to a property on my viewmodel. What i want to achieve is to always setting first RadioButton to Checked state, when grid is become visible. Here is some code: <Grid...

WPF/MVVM setting UserControl.DataContext in XAML results in Object reference not set?

wpf,mvvm
Whenever I paste the UserControl.DataContext portion of the code below, I get "Object reference not set" in the designer. I'm pretty convinced it's something inside the view model, but I think it has to do with binding because it runs fine... When the view model loads it makes a call...

Implementing data binding in a MVVM framework

c#,mvvm,data-binding,system.reactive
I'm developing a MVVM framework (C#) and I'm looking for information on how to implement data binding / synchronization (one-way, two-way, multi-binding, etc.). Also, is there any other frameworks I should consider utilizing, e.g. Reactive Extensions?

margin between image and text

wpf,xaml,mvvm
In this code I added an image before the button text I'd like to have a space between the image and text but the code I have isn't working. <Button Height="25" Width="80" Margin="5,10,5,10" Command="{Binding PreviewTemplateCommand}"> <StackPanel Orientation="Horizontal" Height="15" Width="63"> <Image Source="/UILibrary;component/Themes/Default/Images/preview.PNG" Height="15" Width="15" Margin="0,0,0,0" /> <TextBlock >Preview</TextBlock> </StackPanel> </Button> ...

Model or ViewModel when representing a subset of data in MVVM?

c#,wpf,mvvm
If I have a complex model representing a large amount of data, and I only wish to display a cut-down version of that model (e.g. Name, Description), what is the best approach in MVVM? Most solutions I can find seem to assume that the data is already present in memory...

wpf button command binding after trigger the propery changes

c#,wpf,mvvm
i have a button in my wpf form and the button is having the image text in mvvm application when i click the button it will attach the file, my requirement is when it attached successfully the text is changed to Approve , I want to write another command propery...

OnDetaching function of behavior is not called

wpf,events,mvvm,memory-leaks,behavior
I have WPF behavior on specific control. When I close the window that hold the control the OnDetaching function is not called. The behavior continues to exist (because of the events to which it's registered), although the window does not exist anymore (memory leak). Why the OnDetaching function does not...

Viewmodel binding for Edit View

c#,entity-framework,mvvm
Having some trouble with the "GET" part of the Edit View, and can't really find anything online. So far, this is my POST section: [HttpPost] public ActionResult Edit(ContactsEditViewModel viewModel) { if (ModelState.IsValid) { var Contacts = TheContactContext.tblContacts.Find(viewModel.ID); Contacts.Company = viewModel.Company; Contacts.Contact = viewModel.Contact; Contacts.Contact2 = viewModel.Contact2; Contacts.Email1 = viewModel.Email1; Contacts.Email2...

Xamarin MvvmCross ViewModel Validation

validation,mvvm,xamarin,mvvmcross
I'm building my first Xamarin MvvmCross application at the moment and I'm currently looking at validating user input to the view models. Doing a lot of searching around everything (including the MvvmCross team) link to this plugin: MVVMCross.Plugins.Validation This plugin makes use of a very old version of MvvmCross v3....

Cant bind enum to combobox wpf mvvm

c#,wpf,mvvm,combobox,enums
A have read a lot of method about the ways of binding enum to combobox. So now in .Net 4.5 it should be pretty ease. But my code dont work. Dont really understand why. xaml: <Window x:Class="SmartTrader.Windows.SyncOfflineDataWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="SyncOfflineDataWindow" Height="300" Width="300"> <Grid> <StackPanel> <ComboBox ItemsSource="{Binding StrategyTypes}" SelectedItem="{Binding StrategyType}" />...

propertychanged in region from other region

c#,wpf,mvvm,prism-5
I am using WPF + MVVM with prism and unity. I have three regions "menu", "main" and "footer". Now I would like to set a property in the footerViewModel (region "footer") from MainViewModel in region "main". This property should be displayed in the footerView. The change event works but it...

WPF ItemsControl not refreshing

c#,wpf,mvvm,itemscontrol
I'm working on a WPF project. I have a class like this: public class Field { public ReservationDTO reservation { get; set; } public DelegateCommand FieldChangeCommand { get; set; } public bool Available { get; set; } } And I have a collection of it public ObservableCollection<Field> Fields { get;...

WPF implicit datatemplate not displaying view

c#,wpf,xaml,mvvm
fellow programmers. I'm trying to build my first WPF app with tabbed interface. I've decided to not rely on any MVVM framework, since I'm only starting my journey. I've found quite a few tutorials, but can't make WPF to pick up correct view for viewmodels. What I have is Shell...

Define Blend Expression ViewModel definition for RelativeSource binding

wpf,xaml,mvvm,user-controls,blend
I have an UserControl (MyCompositeView) where I add some other UserControls (MyDetailView). To get intellisense and refactoring ability I add to the CompositeView the d:DataContext in xaml. To Manipulate the UserControl while adding them an new DataContext I bind the Visiblity to the RelativeSource (my CompositeViewModel). Unfortunately the matching against...

Why can't I get this simple Knockout code to work?

mvvm,knockout.js
I am new to Knockout and am learning how MVVM works. Here is a code snippet of my code. $(function () { var viewModel = { name: ko.observable("Bob"), changeName: function () { this.name("Steve"); }, nameVisible: ko.observable(true); }; ko.applyBindings(viewModel); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-debug.js"></script> Name: <input type="text" data-bind="value: name, valueUpdate:...

Issues with MouseDoubleClick command on TreeViewItem using AttachedProperties

wpf,mvvm,treeview,attached-properties,attachedbehaviors
I am trying to attach a Command and CommandParameter property to a TreeViewItem so I can route a mouse double click event to a Command in the ViewModel. It appears that the double click event is never even fired. MouseDoubleClick: namespace VisualInspectionConsole.Commands { public class MouseDoubleClick { public static DependencyProperty...

Bindings doesn't work on nested template loaded by JSON in KnockoutJS

javascript,json,mvvm,knockout.js
Yesterday I make this question: How can I refresh or load JSON to my viewModel on Knockout JS with complex models Everything works OK with the fixes but when I try to use a complex json to load in the viewModel some of the buttons (specifically on Groups) doesn't work....

WPF. Change DataContext on event binding to access code-behind on a MVVM project

wpf,mvvm,code-behind,datacontext
i'm developing a WPF application with MVVM. At the XAML code i have a Grid with its DataContext pointing to a ViewModel, and i need to know if it is possible to change the DataContext at runtime to access an event at its code-behind. Code-behind for the view: public partial...

c# mvvm bind views to tabcontrol with header

c#,wpf,mvvm,tabcontrol
I have a wpf programme with a main View (Window)which contains a TabControl to show several different UserControl Views (the sub-views, one in each tab). Every View has an associated ViewModel. I wish to bind the TabControl so that I just need to load a new sub-view into the ApplicationViewModel...

WPF MVVM custom Sorting issue

c#,asp.net,wpf,sorting,mvvm
I am trying to create custom sorting WPF Data Grid. I have did database call on every sorting. I have used MVVM for this. Issue is I am always getting Sort Direction of column always null on sorting event when I make DB Call. If I remove UpdateData method from...

How can i add different images to combobox itemssource array

wpf,mvvm
I would like to add different images next to each item in a combobox itemssource. Here's what i have at the moment. <ComboBox x:Name="cmb" HorizontalAlignment="Left" Width="135" Height="22" SelectedItem="{Binding myViewMode}" Margin="5,0,0,0"> <ComboBox.ItemsSource> <x:Array Type="sys:String" xmlns:sys="clr-namespace:System;assembly=mscorlib"> <sys:String>Oranges</sys:String> <sys:String>Mangoes</sys:String> </x:Array> </ComboBox.ItemsSource> </ComboBox> How should add the two...

MVVM Light DataGrid binding

wpf,mvvm,data-binding,datagrid,mvvm-light
I'm developing a WPF with C#, .NET Framework 4.5.1, MVVM Light framework and Entity Framework 6.1.3. I have this DataGrid in a window: <DataGrid x:Name="LevelConfigurationDataGrid" Grid.Column="1" Grid.Row="1" Margin="20,0" ItemsSource="{Binding LevelConfigs}"> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding CODE_LEVE}" Header="Nivel"/> <DataGridTextColumn Binding="{Binding CODE_NAME}" Header="Nombre"/> <DataGridTextColumn Binding="{Binding IS_ACTIVE}" Header="¿Activa?"/> <DataGridTextColumn...

How do I re-use the same control twice but keep state between them

wpf,mvvm
I have a control which I need to use twice in an Options dialog, but I need to somehow keep and know the state of each control. The control has a few checkboxes, and some "entity" has to know which of those are checked in which control. I tried 2...

AvalonDock cannot disable floating

c#,wpf,mvvm,avalondock
I cannot disable floating for my LayoutAnchorablePanes. My xaml looks like this <DockPanel> <ScrollViewer HorizontalScrollBarVisibility="Disabled"> <Grid> <avalonDock:DockingManager x:Name="dockManager"> <avalonDock:LayoutRoot> <avalonDock:LayoutPanel> <avalonDock:LayoutAnchorablePaneGroup DockWidth="420" Orientation="Vertical"> <avalonDock:LayoutAnchorablePane > <avalonDock:LayoutAnchorable Title="Main" CanClose="False" CanHide="False" CanFloat="False" ContentId="1">...

Create button grid dynamically and bind its text values?

c#,wpf,mvvm
I actually have two questions. I'm working on a Cinema project in WPF (which is connected to an asp.net webservice). On a view I have to show all the reservations of one performance, and for that I need something like a grid on my view, to show all the seats...

Progressbar for filling TextBox using MVVM Light Toolkit in WinRT

c#,wpf,xaml,mvvm,windows-runtime
I have a form containing few TextBox elements and a progress bar. I want the progress bar to be updated when the TextBox's have some values assigned. So when a value is set to a TextBox I increment ProgressPercent if the lenght is different from 0; The problem is that...

Starting app in WPF, how to not use a startup uri, but a window instance

c#,wpf,mvvm
I'm working in a shop that has adopted MVC influences into the WPF\MVVM paradigm. In this realm, the controller is newed up first, which would new it's view and the view model (via MEF). I'm wondering how to get into the app.xaml.cs to hand it a created window (and it's...

Setting binding on usercontrol to mainwindow's ViewModel

.net,wpf,xaml,mvvm,data-binding
I have following user control <UserControl x:Class="Station.Controls.FilterTraceDataControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d"> <TextBox x:Name="PartNumbTextBox" Width="120" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="5,0,0,0" Height="25"/>...

MVVMCross WPF Value Converter with Tibet Binding Is Not Converting?

wpf,xaml,mvvm,mvvmcross,valueconverter
I am trying to make a value converter which takes a bool and returns the negation of it. The value converter itself is simple: namespace MyProject.Core.ValueConverters { using System; using System.Globalization; using Cirrious.CrossCore.Converters; public class BoolNegationValueConverter : MvxValueConverter<bool, bool> { protected override bool Convert(bool value, Type targetType, object parameter, CultureInfo...

ViewModel properties for properties of nested classes inside the model

c#,wpf,mvvm,nested-class
I have an application following the MVVM pattern, that has to serialize XML files. As some of the XML attributes are nested, I've created nested classes inside my Model, like this: public class OPER_FILE { public UNB unb { get; set; } public OPER oper { get; set; } //nested...

Correct way to save data with mvvm when navigating between pages

c#,mvvm,mvvm-light
I'm working on a universal app but I'm confused as to what is the best way to save data when using MVVM. I'm using MVVM light with this project I have a page (i.e. LocationsPage) with a ListBox binded to an observable collection that contains objects of type LocationViewModel. There...

Asynchronous MVVM commands

wpf,asynchronous,mvvm,async-await,task-parallel-library
I have been following the rather excellent series of articles by Stephen Cleary in the MSDN magazine (Patterns for Asynchronous MVVM Applications) and have been using his IAsyncCommand pattern in a "hello world" style application. However, one area that he does not address is when one needs to pass in...

Should I be using more than one viewmodel for a database table?

c#,wpf,mvvm
Bit of confusion, which I'm sure can easily be cleared up :). Lets say we have a table called "Contacts". The "Index" view for this table would be a datatable, listing all contacts in the table with First name, email and phone. Now, this would have a viewmodel containing Firstname,...

Update progressbar from thread- MVVM

c#,wpf,multithreading,mvvm,thread-safety
I am new to MVVM pattern. I have a problem updating progressbar from another thread. View.Xaml <ProgressBar Value="{Binding ProgressBarValue}"> ViewModel.cs public int ProgressBarValue { get { return status; } set { this.status = value; this.RaisePropertyChanged(() => this.ProgressBarValue); } } Thread th; private void OnOk() { th=new Thread(new ThreadStart(StartProcess)); } private...

Proper MVVM ViewModel and Model pattern

c#,wpf,mvvm
I haven't found an exact answer to this. Some people have mentioned that binding directly to the model as inappropriate for MVVM, however I'm trying to decide if the following pattern still follows MVVM: View: <TextBox Text="{Binding InfoForProcessing.BatchId}"/> <TextBox Text="{Binding InfoForProcessing.BatchStatus}"/> ViewModel: private ProcessingTaskModel _infoForProcessing; public ProcessingTaskModel InfoForProcessing { get...

add image to the button

wpf,xaml,mvvm
Here is the code for my button in the project, my requirement is i want to add some image(c:\1.jpg) before the button text "attach approval" and after the button is clicked the button name is changed to "approve" after it is changed i want to add another image(c:\2.jpg) <Button ToolTip="Attach...

Remove previous ComboBox SelectedItem from its next appearance bind through List

c#,wpf,mvvm
I have a ComboBox and TextBox like <TextBlock Grid.Row="0" Grid.Column="0" TextAlignment="Center" VerticalAlignment="Center" FontSize="16" FontWeight="Bold">Products :</TextBlock> <ComboBox Grid.Row="0" Grid.Column="1" Margin="10" Height="30" ItemsSource="{Binding Path=LstProducts}" SelectedItem="{Binding Path=Items.Product}"/> <TextBlock Grid.Row="0" Grid.Column="2" TextAlignment="Center" VerticalAlignment="Center" FontSize="16" FontWeight="Bold">Cost :</TextBlock> <TextBox Grid.Row="0"...

How to display images from ObservableCollection in mvvm

c#,wpf,xaml,mvvm,bitmap
I'm still tyring to get my head around MVVM. I got stuck on displaying my images which paths are stored in an observableCollection. In the past I could make it would with code behind in the view but now when I'm trying to implement MVVM on my project and it...

Do Data Annotations only work with ASP.NET?

c#,wpf,mvvm,data-annotations,ef-database-first
This is a serious question, because for the life of me after 2 days I still can't get Data Annotations to work with my classes in a WPF application. And it seems every Google article involving data annotations mentions ASP, MVC or some other web based thing I'm not using....

Combobox and IDataErrorInfo

wpf,vb.net,mvvm,combobox,idataerrorinfo
This is my problem. When I select an item from the combobox, (combobox is populated) I have always red outline. Why ? <ComboBox x:Name="Cmb_USER" TabIndex="5" ItemsSource="{Binding User_USER, ValidatesOnExceptions=True, ValidatesOnDataErrors=True,NotifyOnValidationError=True}" IsEditable="True" DisplayMemberPath ="DescUser" Text="{Binding Path=USER}" Margin="114,105,98,179"/> Public Property User_USER As ObservableCollection(Of Model_User) Private p_USER As String Public Property USER() As String...

MVVMCross, WPF, XAML “Unable to resolve the binding creator - have you initialized Windows Binding”

wpf,xaml,mvvm,binding,mvvmcross
I am trying to make a simple WPF application using MVVMCross that has two views and two view models. All I want to happen is for a button on the initial view to open the second view, using the MvvmCross.BindingEx.Wpf nuget package. Here is the first tag in my XAML...

WPF Change Binding values on update

c#,wpf,mvvm,data-binding
I have a ListView that is as follows: <ListView ItemsSource="{Binding OrganizationInfo}"> <DockPanel> <StackPanel Width="130"> <!-- Name --> <Label Content="Organization Name" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" Margin="4" Height="25" /> <!-- Street 1--> <Label Content="Address 1" VerticalContentAlignment="Center" HorizontalContentAlignment="Right" Margin="4" Height="25" /> <!-- Street 2--> <Label Content="Address 2" VerticalContentAlignment="Center"...

WPF Prism + Existing WPF Application [closed]

c#,.net,wpf,mvvm,prism
I've an existing application. With about 3 years of good experience with WPF/MVVM - I feel I should have started with Prism (I've no knowledge of PRISM framework as of now - and I plan to learn it now). Goals are to - - Make the appication a SOLID (design)...

How can addCls to Button with ViewModel binding in ExtJS5

javascript,extjs,mvvm,extjs5
I want to change css class after binding. Is it possible in ExtJS5? I added to comments. fiddle: https://fiddle.sencha.com/#fiddle/olc...

MVVM - Validating the model when a field in the viewmodel is changed

c#,wpf,validation,mvvm,ef-database-first
I'm using the MVVMLight libraries with a Database-First EF model. I can't quite figure out how to validate the model when a certain field in my viewmodel has changed. This works fine when I'm updating individual Properties of the model as I have a call to Validate in the set...

How to call StyleSelector on PropertyChanges of a row

c#,.net,wpf,xaml,mvvm
I have RowStyleSelector with datagrid. It's called correctly on load of the window. On changes of rows when I call PropertyChange it's not called. <DataGrid Grid.Row="2" ColumnWidth="*" ItemsSource="{Binding TraceItemCollectionViewSource , Mode=TwoWay , UpdateSourceTrigger=PropertyChanged}" EnableRowVirtualization="false" RowStyleSelector="{StaticResource TraceRowStyleSelector}" IsReadOnly="True" Name="TraceDataGrid" Margin="5,5,5,5" Padding="5,5,5,5" AutoGenerateColumns="False"> This is my model: public class TraceDataItem :...

WPF Navigation using MVVM

c#,.net,wpf,mvvm
I'm trying to follow the answer provided in this post, but I must be missing something trivial. I've defined my DataTemplates as App.xaml as follows: <Application.Resources> <DataTemplate DataType="{x:Type vm:BlowerViewModel}"> <v:BlowerView /> </DataTemplate> <DataTemplate DataType="{x:Type vm:HomeViewModel}"> <v:HomeView /> </DataTemplate> </Application.Resources> Then, in my MainWindow.xaml I've defined the following code: <Window x:Class="App.MainWindow"...

How to use the value of textbox in mvvm commands

c#,wpf,xaml,mvvm,icommand
I'm still figuring out mvvm and I want to make my app the right way by splitting up model viewmodel and view. In the past I always took the value of the textbox in the view directly by using mytextbox.Text. I created a command in the viewmodel to add a...

Checkbox not showing as checked inside ListView

wpf,mvvm
I have a checkbox inside a listview. The listview is bound to an observable collection. When I use the context menu to try to select all Checkboxes, they do not show as checked. What am I doing wrong? <ListView Grid.Row="1" Grid.Column="0" ItemsSource="{Binding AvailableModels}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SelectionMode="Extended"> <ListView.ContextMenu> <ContextMenu> <MenuItem Header="Select...

WPF & MVVM, right way to do it

wpf,mvvm
So I am doing my first WPF MVVM app. Just learning the right principle of MVVM, but there are some things that I don't understand ... I already have several user controls defined. First question is what is better to use, UserControl or DataTemplates to change content of the MainWindow?...

Selected property in ComboBox not shown

c#,wpf,xaml,mvvm
I have a ViewModel which has a collection and a property representing the selected value in the collection. In my view this is shown in a ComboBox. When "filling" my ViewModel, the selected item is not shown in my view. My ViewModel public class DriverViewModel : MasterDataWithAddressViewModel<Driver> { public ObservableCollection<Vehicle>...

WPF MVVM add row with two controls to Grid/DataGrid dynamically

c#,wpf,mvvm,datagrid
I am studying mvvm and face this problem with dynamic addition - in simple win forms I have done this easily with one loop and just few specification to DataRow.. So, the task is - to put all elements from List of strings to Grid/DataGrid, that contains two columns -...

How to change Views using the NavigateToPageAction?

c#,xaml,mvvm,eventtrigger,windows-universal
I've set up a NavigateToPageAction to navigate to a new View on an AppBarButton click, but the second event trigger I've set up doesn't navigate to the specified View, "ViewSubjectGradePage" The first trigger works when navigating to "AboutPage" which is identical, so not sure why it doesn't work the same...

What executes first: ToggleButton.IsChecked binding update, or Command binding?

c#,wpf,mvvm
First - a disclaimer: If you're reading this because you want to use both a binding for IsChecked and a RelayCommand to change things, you probably are doing it wrong. You should be working off of the IsChecked binding's Set() call. The question: I have a ToggleButton in which there's...

WPF ListBox select next item after deletion with ICommand

wpf,xaml,mvvm,datagrid,listbox
This question evolves kind of the same issue like this question, but it concerns a different problem that I face because I use bindings. I have added a button to delete the currently selected item from a ListBox (and one for a DataGrid where the same problem arises). The code...