C# - Reusing A Menu With Mvvm And Wpf?
Jun 7, 2011
I was wondering what the best approach is for sharing a menu across all wpf windows/views. My Application doesnt really fit the navigation model, so will probably use a Ribbon control. I am leaning towards creating a user control for the menu and dropping it on each view, but have also seen Josh Smith's msdn article, where he loads user controls.
View 2 Replies
ADVERTISEMENT
Mar 26, 2010
created a menustrip (MenuStrip1) by dragging the tool onto my form (form1.vb). And designed the headings/items etcI have now created another form (form2.vb) within the same project.I would like to use MenuStrip1 that i designed for form1.vb in my new form2.vb.
View 6 Replies
Jun 7, 2009
I am working in vb2008. Is there a simple way to clone the contents of a datarow in a datatable into a new datarow instance that can be added elsewhere in the table. Can I create a new instance of a datarow and set it equal to an existing datarow?
View 5 Replies
Jun 20, 2012
Say I have a connection to a database. After reading some stuff I want to connect to the same database. So I naturally use the first database mysqlconnection.serverstring the password and username is not included in connect1.ConnectionString. So how can I do so? Is this by design?
[Code]...
View 3 Replies
Apr 13, 2009
In the code below can I use the cmd for another sql command or do I have to create a new sql command like shown below?
View 2 Replies
Nov 1, 2011
I am upgrading a system that has a Product Table with a Product No Field.This is a string field but most of the existing product Nos are numeric but all over the place.I want to provide a default numeric Product No when the Users are creating a new product record.All I can think of is to use the Identity Field [ProductID] and test to see if it has been used and if so keep incrementing to find the next free numerical, available No.A better solution would be to start at 1 and increment to find the first available but it looks to be several hundred records into the Table. how to find the first available number?
View 9 Replies
Oct 8, 2010
I'm attempting to run different tasks in there own processes, waiting until each is done while keeping the UI responsive. So far it works exactly how I want it until I try to reuse some of those processes....here is a sample of the
Private WithEvents TaskOneProcess As Process
Private WithEvents TaskTwoProcess As Process
Private WithEvents TaskThreeProcess As Process
[code]....
This is a over simplification of what's going on but it gets the point across. So it works exactly as expected, a button is pressed and the sequence starts. As each task gets disposed it recalls the StartFixing statement which then calls the next one in order until they are all done. BUT when I go to do it a second time the Disposed never fires assuming since it's already disposed. How do I recreate the same named process so it can be reused and still have it fire the disposed event?
View 2 Replies
Mar 22, 2012
I have a set of controls and code behind them that I'd like to reuse on multiple forms. How can I do this? I know of reusing code via modules, but I'm not sure how I can add the same controls and their underlying code. If I achieve this, will changing data on one form affect the values of another form when they're both open? For example...
Cbox1's selected item affects the choices within Cbox2, and Cbox2's selected item affects the choices within Cbox3 (and so on).
So if I do something on Form1's Cbox1 and it changes Form1's Cbox2, will it NOT change Form2's Cbox2?
View 4 Replies
Nov 11, 2010
Not sure if this has been asked before (couldn't find an answer), but is there a way to reuse a user.config file from a previous version of the application? For example a user.config file is stored in:
C:UsersJohnnyAppDataLocalCompanyApplicationName.exe_Url_wxcnyrmstqy3oj1qwckdjq3gjqkq4fel1.0.0.0user.config After a new version is installed it gets stored in:
C:UsersJohnnyAppDataLocalCompanyApplicationName.exe_Url_wglmejvw01nagu5t1y5yl12chynjomny1.0.0.1user.config The user then has to enter all settings again, even if the new version does not save more settings. An other problem is that although the user.config file is very small, it does get messy after a while when newer versions of the application get installed. Is there a way to clean up the unused user.config files and their folders?
It's the same problem with System.Windows.Forms.Application.LocalUserAppDataPath, that I'd like to use to save other files (containing Listview data), which points to:
C:UsersJohnnyAppDataLocalCompanyApplication1.0.0.0 The Listview data and other files created by the app can't be used anymore.This can be solved by getting the user's appdata folder with Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) and creating a new folder there with the name of the application. But this means there's one folder where the application is installed (user can choose this folder in the installer), one folder to save my own files to and one folder where VB stores the user.config file.
Can something be done about this "mess" or is this just something I have to live with?
View 2 Replies
Mar 30, 2010
I save the size of a form to a variable (One Size or two Integer variables--doesn't matter), and then I close the form. Before reopening the form, I set the form size to the size I saved before--which by all accounts of logic and reason should exactly the same. Except, no, it's not. On one system the form "grows" horizontally and vertically by 15 or 16 pixels. On another system the form grows only vertically 15 or 16 pixels. I'd love for someone to explain this perfectly insane, yet MS typical, behavior to me.
[Code]...
View 5 Replies
Dec 28, 2010
I am very familiar with modules from my time with VB and my other programming, but what is the most commonly used practice and the best way to go about this for a website application with ASP.NET? Say I have multiple pages (in multiple directories; some in the root directory, some in child directories from the root) that will call the same set of functions and subroutines, how do I go about putting this reusable code in a place where the pages and their respective classes can call the functions/subroutines?
View 3 Replies
Aug 1, 2011
First of all, I wasn't sure whether this was VB.NET or General Developer content... It's not technically about VB.NET code, but it's not very general either since it is specifically about Visual Studio. Feel free to move it if required.A while back I realized that all of my database connection code was getting very biolerplate. had 'developed' my own method of connecting to an Access database and storing the results. Basically, for each table I create one 'Manager' class and one 'Entity' class. The Entity class represents a single record in the database and has properties for each field.
View 9 Replies
Mar 14, 2011
I'm wondering if someone can point me towards a good article/tutorial explaining how to use the MVVM pattern in an WPF Application that uses WCF web services. My WPF client calls a service reference to get data objects that contain data from the database but from everything I've seen and read so far about MVVM I am still not clear on how to use MVVM to work with the data objects I am retrieving from the WCF services.
View 1 Replies
Sep 26, 2009
Almost every example of MVVM I found is coded in C#, are there any examples/tutorials coded in VB.Net? I'm having a hard time translating C# to VB.Net since I haven't really used C# in any meaningful way...Also, does a MVVM Template/Toolkit for VB.Net exist yet?
View 4 Replies
Feb 3, 2011
I am currently developing a new WPF application and have the majority of my business logic layer developed (ie my Models). I am about implement ViewModel classes to represent one feature of my application. I am quite new to the Model-View-ViewModel pattern and I have a question about which approach would be best to use when implementing my ViewModel classes.
[Code]...
View 3 Replies
Nov 11, 2009
IM Looking at Implementing MVVM in Silverlight.Kind of new to Silverlight and I'm Definately new to MVVM Pattern.I get it all But I want A set of small Prism VB.Net MVVM exmaples if that makes sense.
View 1 Replies
May 25, 2011
I have been getting up to speed with the MVVM pattern in Silverlight and was wondering how to implement binding from the View to the ViewModel when the ViewModel constructor has a parameter if an interface type.If I bind the viewmodel to the view in XAML then you can not use a parameterised constructor. Given that I was creating a default constructor passing an instance to the parameterised constructor but this breaks the abstraction.
View
<navigation:Page x:Class="QSmart.DataViewer.Report.RecentFailures.Report"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
[code]....
Is it recommended to use the code behind of the view to pass into the parameterised constructor and then bind to the viewmodel?
View 1 Replies
Feb 28, 2012
I have just started using MVVM design pattern with unity and I'm strugling to work out how you add a constructor.my code currently works if I comment out my constructor that requires input the view gets added to the shell.
Protected Overrides Sub ConfigureModuleCatalog()
MyBase.ConfigureModuleCatalog()
Dim moduleCatalog As ModuleCatalog = CType(Me.ModuleCatalog, ModuleCatalog)
moduleCatalog.AddModule(GetType(GridModule))
End Sub
how do I pass in variables into my GridModule ?
View 5 Replies
Mar 22, 2011
I have a simple LoginForm.Here is how the code-behind looks like:
Private Sub btnLogin_Click(sender As Object, e As RoutedEventArgs) _
Handles btnLogin.Click
If Me.loginForm.ValidateItem() Then
[code].....
View 1 Replies
Apr 15, 2012
I'm attempting to improve my MVVM abilities in my next WP7 App (which is written in Vb.NET). I have a textbox that has been given focus and has a WP7 keyboard displayed. I am using command binding and a xyzzer's bindable Application bar (which is excellent).[URL] I want to be able to cancel the focus of the TextBox from the ViewModel, by setting focus on the form. Normally (Non MVVM) I would do this from within the form by calling:
[Code]...
View 3 Replies
Feb 16, 2012
I'm trying to get a DataGridComboBoxColumn working with my ViewModel. Everything appears to work correctly but when I change the value of the combo box, the entity isn't changed. The datacontext of the window has these properties:
[Code]...
View 4 Replies
Sep 17, 2010
As my company migrates towards the .NET framework from VB6, it looks like we are going in the direction of WPF (my boss is in love with the Office-style Ribbon control). I've been working to mock one of our VB6 applications in WPF and decided to experiment with MVVM at the same time. I'm being discouraged from using an existing MVVM framework, so I guess I need to write my own. The biggest concern right now seems to be a method for registering and managing all my views from a central spot - a manager class - but I'm not exactly sure how to implement this.
View 4 Replies
Jul 14, 2011
Possible Duplicate:How can I handle a Validation.Error in my ViewModel instead of my View's code behind?The usual examples of how to use Data-Validation in WPF usually only involves defining an error template for the control and displaying the error message in the control tooltip. What I want to do is to create a collection of all ValidationErrors, display it in an ItemsControl to the user and focus the invalid control when the user clicks on the associated (error) item in the ItemsControl.
View 2 Replies
Mar 26, 2012
SEE MY ANSWER AT THE BOTTOM Just doing some light reading on WPF where I need to bind the selectedItems from a DataGrid but I am unable to come up with anything tangible. I just need the selected objects.
[Code]...
View 3 Replies
Oct 12, 2010
I'm hacking away at some code which seems to have been started, at least in theory, as an MVVM project in Expression Blend, by my predecessor at this company.
I've got a thread running in the background, which is running some operations on items as they happen. In order to prevent any clashes, I've also got that thread running any operations my users call for.
Once those operations are completed, I'd like to bring up a MessageBox to give a summary of the user-initiated operations, but now that they're running off in their own thread, the finishedProcessing event handler is now running on the background thread instead of the interface thread and it's causing my MessageBoxes to appear non-modally.
Back in the WinForms days, I'd have handled that using InvokeRequired, Invoke and a Delegate. I've read that this has been replaced by something called "Dispatcher", but the ViewModel class I'm using doesn't seem to have a Dispatcher object.
The "thisViewModel" class I'm using inherits a class called "WorkspaceViewModel", which inherits "ViewModelBase", both of which look generated to me...
where I can link up to this "Dispatcher" from here?
View 1 Replies
Jan 4, 2011
How do i fill my ObservableCollection(of Monitors) with data so that I can save it in an MVVM friendly manner. I normally use a FileNumber to load a DataSet using a DataAdapter and pass the monitors table via monitorDT - should I be loading it differently? How do I save the changes? Right now I have the following for loading data:
[Code]...
View 1 Replies
Jan 13, 2011
How do i fill my ObservableCollection(of Monitors) with data so that I can save it in an MVVM friendly manner. I normally use a FileNumber to load a DataSet using a DataAdapter and pass the monitors table via monitorDT - should I be loading it differently? How do I save the changes?Right now I have the following for loading data:
Public Class Monitors
Inherits ObservableCollection(Of Monitor)
Public Shared Function LoadMonitors(ByVal monitorDT As DataTable) As Monitors
[code]....
View 3 Replies
Jul 4, 2011
Something that has been confusing me for a while now with WPF MVVM is for example, when I have a base model containing nothing but a few properties and some validation code and I then build a view model around this base model, how should the view model be structured.
For Example:
Base Model ->
Imports ModellingHelper
Imports FTNHelper
[Code]....
What I am wondering is, if there is a better way to structure the view model to improve data binding, so I don't have to bind to Source.Name etc. How should I handle the base model in the view model?
View 2 Replies
Mar 23, 2012
I have been trying to do this for ages and having no joy whatsoever.
I have a ribbon window of the following hierarchy:
MainWindow
MainContent (Tab Control)
TabContainerViewModel
ViewModelBase
View model base has an ObservableCollection of tabs type ViewModelBase. The Tab Control itself is binding fine to these, displaying appropriate view models. I have 2 problems however, I want a "NotepadView" (Of type viewmodelbase) to be replicated numerous times (one view many view models).
At the minute, I have 4 views (NotePadViewModelx where x is 1-4) with corresponding viewmodels, this is because each view had the same text per tab. Now I have individual views per tab.
When I type into tab 1 and switch to tab 2, I lose what I typed in tab one when I click back.
View 2 Replies
Mar 14, 2012
This is more a conceptual question. Here is my current predicament; I am writing a vb.net WPF application and using the MVVM pattern (love it! maintainability is just amazingly awesome). Currently all the code is written by hand and there is no use of NHibernate or Entity Framework as the backend is an access database (due to policy I cannot use NH and EF doesn't support JET Databases, we may switch to MSSQL at some point but that may be a while from now).[code]...
View 1 Replies