Put RadGrid in insert mode via command - wpf

I need to put the grid in insert mode when a user clicks an Add button (he doesn't want the click on the grid, but an external button)
Since I've developed all my app using MVVM pattern, I was wondering if there's a way I can put the grid in insert mode via command
Any suggestion?
Thanks

The RadGridView comes with some built in commands, one of which is begininsert.
There's sample code shows how to invoke such commands on telerik's site:
https://docs.telerik.com/devtools/wpf/controls/radgridview/commands/overview
Since this is manipulating the state of a control then you can use code behind in the view and a click event without "breaking" mvvm. You can't run automated tests on this processing using just the viewmodel anyhow - since the viewmodel isn't going to know anything about a gridview, let alone any mode it's in.

Related

WPF MVVM: Decouple view bindings and dynamically setting bindings

I'm writing a fairly large WPF application that is following the MVVM structure. I would like to run my UI in basically 2 modes. The first being the normal day-to-day operational mode. The second is one that I've been wondering about for a while now...I would like to be able to run it in a "configure" mode where the user will see the UI in more or less the same fashion as the normal mode, except that a popup window would appear when they hover over (or maybe click) a control. This popup would allow the user to change certain bindings related to that control. I don't want to expose every property (or every control).
For example:
There is a TextBlock that has a binding to a pressure signal, now that user wants to change this binding to a temperature signal. They could start the UI in config mode, navigate to the screen with the TextBlock, select it, and see the Text property in a popup which they can then change to the new temp signal. This is a simplified exampe, but basically what I'm looking to do.
Is this possible? Remember the UI would have to write to the the View (XAML). Any help is appreciated.
P.S.
This would be a very useful but rarely used feature. It would be ok to maybe have 2 projects which ustalize the same View but different ViewModels and Models...at least that's what I've been thinking might be needed. Even if the normal mode UI would have to be recompiled after using the configure mode UI.
Every popup window should have its own VM (or they could share if it turns out to be an overkill due to small number of properties per popup) and communicate with the main VM via the message bus.
Store your bindings as User Settings and when the message arrives from the popup window VM, carrying the new binding as a payload, main VM would get that payload and save the appropriate user setting by simply calling Settings.Default.Save();
Based on your description, no reason to make it more complicated than that IMO...

How to update or refresh the contents of a ComboBox in a WiX dialog?

I would like to implement the well-known scenario whereby the contents of a ComboBox in a WiX dialog depends upon the contents of a previous TextBox value, as input by the user. This will allow me to drive the installation of a component that needs to run SQL scripts.
First, the user specifies the name of the database server.
Second, I would like the ComboBox to display the list of available databases on said server.
This seems a simple enough request and, as far as I understand it, is not easily supported with Windows Installer / WiX. However, I would like to workaround and implement this behavior as close as is possible.
What would be the closest implementation possible ?
I have tried an explicit pushbutton that triggers a custom action. I have tried a duplicate identical dialog that gets navigated to but I can't seem to combine two behaviors - CA execution and dialog navigation.
The general approach is this:
create a custom dialog which contains the edit box control
create a different dialog which contains the combo box control
on the Next button of the first dialog execute a custom action which populates the combo box on the second dialog
This cannot be done using a single dialog.
Also, you need to write custom code to populate the combo box. You can find some sample VBScript code here: http://www.advancedinstaller.com/user-guide/tutorial-combobox-listbox.html#combolist-examples
It's an example for Advanced Installer, but the sample .VBS custom actions can be used with any setup tool.

Frames vs User controls in WPF

I'm writing a Windows application in WPF. I based my UI in a single menu and a tab control to display different documents or application forms. Since the menu as well as other things are fixed throughout the application, I need a way to display the contents of each TabItem. I have found two:
write a user control for each form, or
using a frame to display the content of each form.
The question
Is there any other single way for doing this. How do they compare in terms of clean code? I mean, in .net forms I only need load the form from the menu.
I know, I should go for any pattern like MVVM, but for this very first time I want to use the default approach.
I go with Frames and host Pages (not user controls). I like Pages over User Controls as the event model seems to have more hooks.

How to execute a command and change focus after a keypress in a WPF app

I have a WPF app that uses MVVM Light and I wish to both execute a command on the view model and change the keyboard focus to a specific control when the user presses ALT+SHIFT+C.
Is it possible to achieve this in an elegant way?
It depends on how the shortcut key is created (if it's like Visual Studio or more like Windows - it means if you have to hold only ALT or all the keys).
But whatever the logic, You will have to first bind an Event to a Command (it might be the event keydown of one of your controls).
In MVVM Light, you will have to use Interaction.Triggers with EventToCommand (there's a lot ot explanations on google and SO)
The logic would be put here in you command.
Then a dependecy property as show here could be implemented for getting the focus.

WPF quick prototyping. See changes without running

I'm doing a WPF application, using Blend4 and VS2010 for editing the XAML files.
One of the most anoying things of this is the process of making small changes and see them in action. As the data in the View is populated from a ViewModel and a Model via Bindings, the things you see in the Blend designer aren't the same you get when you run your application. You need to recompile and "re-run" your application every time you make a change, no matter if it was only to change a pixel in the margin of some element.
I want to know if there is any way to perform quick changes in your XAML and watch them in the real interface.
Like in the Websites, the idea is similar to make a change in the HTML and then press F5 to see the changes.
Maybe you can run "part" of your application to bind the view data to the model, and then change only the "view code" of the xaml.
Do you know if this is possible?
Thanks!
Whether using Blend or Visual Studio, the key to rapid design of MVVM user interfaces is sample data. You can use the same view model at design-time as you you do at run time as long as the data is doesn't access services.
Whether you are using MVVM Light or not, you can use its technique to allow your view-model to detect design time and return different data. You can also read Laurent Bugnion's ideas on sample data here:
WPF: Simulating data in design mode in Microsoft Expression Blend

Resources