Wpf - PageFunction OnReturn And The Default PageFunction Constructor?

Mar 16, 2012

I'm trying to create a Wizard at runtime in VB.NET using the WPF NavigationService and I'm having some problems. I need to add controls to the PageFunction pages at runtime which seems to involve passing arguments to the PageFunction pages when I create them (prior to navigating to them). This means that the PageFunction pages need to override the default constructor and add arguments to it. This seems to work fine.

The problem is that I also need to call OnReturn once I've navigated beyond the first page (to go back to a previous page) but the OnReturn doesn't work unless I use the default constructor on the PageFunction page it is navigating back to. The work around I've been considering is creating some global values that the PageFunctions could acssess at runtime in their default constructor but I can't figure out how to define global variables in the MainWindow that the PageFunction pages can get access to.

View 1 Replies


ADVERTISEMENT

Default Value At Declaration Or In Constructor?

Mar 4, 2011

One would think I'd already know this, but I never really gave it much thought before now. When declaring a member variable for a class, is it better to set the default value at the declaration

Private m_strMyVariable As String = ""
Or is it better to do it in the constructor
Private m_strMyVariable As String

[Code]....

Should I maybe always specify a value at declaration, even if it's Nothing, and just override that value in the constructor(s) as needed? Or is it situation specific? If so, a really quick rundown of which situations might warrant which treatment would be nice.

View 4 Replies

C# - MVVM ViewModel Default Constructor?

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

VS 2010 How To Eliminate Default Constructor

Jan 19, 2011

I have written a number of classes in my time in VB.NET which set the basic elements in a custom New constructor through parameters. This makes things easier and enforces discipline. However, using Public Sub New() becomes pointless. If someone else tried to use this class, he or she could make a mess of it all by using Sub New without the arguments. I'd like to remove this method but I haven't found out how. I could make it raise an exception, but that somehow seems unseemly. I'd like a neater way. Does anyone know how?

View 22 Replies

VS 2008 - Creating Default Constructor Within Class

Feb 3, 2010

I'm doing a lab for school, and I came across something I have never done before: create a default constructor within my class. It involves creating a private field to store the connection string, then create a default constructor that sets the connection string.

Here is what I have so far:
Public Class Appointments
Private sqlconnection As String = ConfigurationSettings.AppSettings("ConnectionString")
Private Property connectionstring() As String
Get
Return sqlconnection
[Code] .....

View 3 Replies

VS 2010 Dll That Is Implemented By A Class With A Default Constructor

Dec 27, 2010

I have a base class which must be overriden. This base class sits in one dll shared by all. The derived classes will each be in their own dll such that the addition of a new derived class can be done by distributing a new dll. The set of dlls, and therefore the set of derived classes, will be discovered by the main program on startup. That's all pretty straightforward. The problem is that the main program needs to be able to query a database to figure out which type of derived class it needs, then create a class of that type. Naturally, it can't know which types will be available ahead of time because even I don't know that. The program has to be dynamically extensible.The obvious way to do this is to have an interface in the dll that is implemented by a class with a default constructor. The sole purpose of that class would be to return an object of the type (one of the derived types) defined in that dll. The derived types can't really be this class, because they can't have a default constructor since the base class doesn't have a default constructor, and the derived class can't make up the arguments that the base class constructor needs.

So basically, each dll that houses a derived class would also house a simple class that implemented an interface for the sole purpose of creating that particular derived class. The main program would examine the dll to find a class that implemented the interface, and once it found one, it could ask it what type of class it created, or it could ask it to create an instance of that class. It seems like there ought to be an easier way to dynamically add new classes to the project. It seems like the derived class ought to be able to tell the main project what type it was. This could be done, except that the derived class would have to exist before any of its methods could be called unless the methods were shared. Since you can't have a shared method in an interface, the interface itself would make no sense at that point, in which case I would need to discover whether the class in the dll derived from the base class in the second dll, just to figure out whether or not I wanted to create it. That's getting convoluted by now, so I guess I'll leave it there. The basic point is that the base class is known to the main program from a common dll. The number and types of derived classes can't be known at this time, so the program has to be able to discover them dynamically. Each derived class will sit in its own dll (or there could be more than one in a dll), and has to be discovered, and instances created, as needed, by the main program.

View 2 Replies

Winforms : Where Is Default Constructor Of A Windows Form

Jan 1, 2011

where can I find the default constructor of a windows form? I mean:

Public Sub New()

End Sub

I should say that I Use Visual Studio 2008 as my editor.

View 3 Replies

Pass A Delegate Into A Constructor Of An Abstract Class From A Descendant's Constructor?

Feb 15, 2010

I have an abstract class which requires a delegate to function. I pass the delegate into the constructor. Now that I have a non default constructor I need to call the abstract class's constructors from the concrete class which means that I need to use MyBase.New(...). I have included a quick example below.

Public MustInherit Class BaseClass
Public Delegate Sub WorkMethod()
Private _Work As WorkMethod

[code]....

I have tried to do this but I keep getting the following error: "Implicit reference to object under construction is not valid when calling another constructor".Can I not do what I am trying to do above? I initially had the delegate setup in its own setter method. But then I am creating a deceptive API because it does require a point to a method to work properly.

View 3 Replies

Why Is Constructor Call Valid Only As The First Statement In An Instance Constructor

Nov 2, 2009

what's the rationale behind this limitation: Constructor call is valid only as the first statement in an instance constructor i want to pass an argument to my constructor which validates this argument and calls mybase.new according to this argument but it doesn't let me

example:

Public Class prob
Inherits System.ApplicationException
Public Sub New(ByVal problem As String, ByRef inner_exception As Exception)

[code]....

View 16 Replies

User To Select Just Straight To Default Printer With Its Default Settings

Dec 3, 2011

I need to print the contents of 3 textboxs to default printer. what examples I have found dont seem to work. I was trying the documentprint1 component as i thought it would be easy but cant figure out how to tell it what to print the second part is to print a variable (string) to the printer as well.no need for user to select just straight to default printer with its default settings

View 1 Replies

VS 2010 Combobox Default Value - Display The Name Of The Person Who Is Doing The Selection As The Default?

Nov 25, 2011

I have a combobox which contains a sample of names selected from a table.Currently the default name displayed in the box is the 1st name found in the table. What I would like to do is display the name of the person who is doing the selection as the default. The name is stored in a public variable 'PubName' and I do not want the user to be able to type into the combobox themselves.Is this possible?

View 2 Replies

Own Browser Becoming Default/Editing Internet Default Options?

Jun 9, 2012

I am creating my own browser. I want to make an option...to set as the browser to default.To do that I have to:Write a code which opens html(generally internet) file through my browser(form load event) DoneChange the "open with..." of the .html,.xml.... files Problem I want to change the open with event from my web browser. Actually i want an options form which will ask the user "Do you want to set /Browser name/ to be your default browser?" If yes then it will change the default options of the internet files.

View 5 Replies

IDE :: Set Project Default For Winforms Projects S/ Default Modifier For Controls Added To Winforms Is Private

May 28, 2010

Is it possible to set a project default for VB.NET winforms projects so that the default Modifier for controls added to winforms is Private (not Friend)?I know there's a "modifiers" property in the properties window so I can set it for each individual control however I would like to change the project so from now on myself and other developers have to specifically decide to change from friend to private. (Which I would strongly discourage them from doing).I believe there is no way of doing this, but on another forum a while ago someone mentioned it would be possible with an add-in (but didn't name the add-in or where to get it).

View 1 Replies

C# - Attribute's Constructor Run?

Jul 22, 2009

When is it run? Does it run for each object to which I apply it, or just once? Can it do anything, or its actions are restricted?

View 3 Replies

Code The Latter Constructor?

Apr 1, 2010

A project has a class (CAR Class) with the folloiwng details and the CARADMIN cLASS with the following details: The cardAdmin class has 2 constructor Public Sub New() & Public Sub New(ByVal rec As Rectangle) I dont know how to code the latter constructor..

cAR Class has this method/properties:

Public Class Car
Inherits HVSprite
Private fSoundFile As String

[code].....

View 5 Replies

How To Call A Constructor From Another

Jun 27, 2009

I have a defualt constructor that has a object of a Database connectivity class:[code]therefore in theory i have to call the defualt constructor of Question from overloaded constructor. [code]How every in realitty is it possible to call the defautl constructor from the overloaded constructor

View 5 Replies

How To Convert Constructor To C#

Aug 17, 2010

Do not know how to convert Me.Base to C#Imports Microsoft.VisualBasic

Public Class ReplaceHTML
Inherits System.IO.Stream
Private Base As System.IO.Stream

[code].....

View 2 Replies

Pass Value Other Than From Constructor?

Jan 23, 2009

how to pass value other than from constructor.

In my code....value are usually passed through constructor.

ie everything is declared in constructor and while executing, these values are defined in new object.

View 3 Replies

Static Constructor In .Net?

Feb 9, 2010

I am rewriting a C# class in VB. The C# class has a static constructor in it:

static Class()
{
...
}

which, through the Call Stack, I found is called by the main window's InitializeComponent() method.Everywhere I've looked has told me that the corresponding static constructor in VB is just:Shared Sub New()

but this method is never invoked. Am I creating my VB static constructor right? Is it likely something else that has nothing to do with my static constructor?

View 1 Replies

<Attribute>: ParamArray In Constructor

Nov 10, 2010

A former co-worker wrote a class in C# that was to be used as an attribute. I'm having to convert his work to VB (yeah, it's pointless and way more work than necessary, but management thinks it's a good idea). Unfortunately I'm having an issue because one of the main properties of the class is an ArrayList which is set with a ParamArray in the constructor. The class looks like this (note I've tried to abstract out the problem, so this is a simplified version of the class only)

<AttributeUsage(AttributeTargets.Field Or AttributeTargets.[Property])> _
Public Class LabelAttribute
Inherits Attribute
Public Sub New()

[CODE]........

In the first one, there is just the single label being added. No Problem. In the second one there are 2 different labels being added. Again, no problem. The third one, however, is a problem because it's assuming that the "Description", which is supposed to be the description is instead being interpreted as another label.

This wasn't a problem in C# because it could be set as follows:

[CODE].................

Of course this doesn't work in VB because optional parameters aren't referred to by name as they are in C#. As a stopgap I've changed the constructor to allow only a single label like this

CODE]..................

But that undermines some of what this class is meant to do. Does anyone know how, or even if I can get the same basic functionality to work in VB?

Think there must be a way to make the existing design work. Imagine this class was built into a library that I could not modify. Would I be forever forbidden from setting Description because of this design?

View 4 Replies

.NET Constructor With Parameters And Inheritance?

Jun 29, 2010

Why VB.NET (vs C#) does not "inherit" the constructors with parameters?

Public Class StopLine
Inherits Microsoft.VisualBasic.PowerPacks.LineShape
Public Sub New()
MyBase.New()

[code]....

View 1 Replies

Add A Constructor To An Existing Structure?

Oct 31, 2011

I've been searching for a while now and can't find a way to add a constructor to the Rectangle Structure.

Is this even possible without inheriting from the class?

View 2 Replies

Assigning A Rectangle To This Constructor?

Oct 15, 2010

Im having trouble with assigning a Rectangle to this constructor

fTrainAdmin = New TrainAdmin( )

View 2 Replies

C# - What Is Startup Form Constructor

Feb 16, 2012

I need to put following code in the Constructor of my startup form.
JohnKenedy.BusinessSQLEXPRInstaller _ins = new JohnKenedy.BusinessSQLEXPRInstaller(" _ <Installation Display Name>", "localhost", "<New database instance name>", _
"<new database name>", "<database password>", "<database backup filename>");
if (_ins.IsDone == false) _ins.ShowDialog();
if (_ins.IsRestart == true) {
Application.Exit();
this.Close();
return;
}
But I really do not know what the Constructor is and how to access it?

View 2 Replies

C# - Why Are Not Allowed To Specify A Constructor In An Interface

Mar 27, 2009

I know that you cannot specify a constructor in an interface in .Net, but why can we not?

It would be really useful for my current project to be able to specify that an 'engine' must be passed in with the constructor, but as I cant, I have to suffice with an XML comment on the class.

View 7 Replies

Calling Constructor When Using Generics

Mar 9, 2011

I'm not sure if this is possible or not. I have a number of different classes that implement interface IBar, and have constructors that take a couple of values. Rather than create a bunch of almost identical method, is it possible to have a generic method that will create the appropriate constructor?

private function GetFoo(Of T)(byval p1, byval p2) as List(Of IBar)
dim list as new List(Of IBar)
dim foo as T
' a loop here for different values of x
foo = new T(x,p1)
list.Add(foo)
' end of loop
return list
end function

I get:
'New' cannot be used on a type parameter that does not have a 'New' constraint.

View 2 Replies

Constructor With Parameters And Inheritance?

Jun 23, 2011

I searched quickly and not find an explicit answer at the following question:Why VB.NET (vs C#) does not "inherit" the constructors with parameters?

Public Class StopLine
Inherits Microsoft.VisualBasic.PowerPacks.LineShape
Public Sub New()

[code].....

View 2 Replies

Create Application For The BMP Constructor?

Feb 7, 2012

I trying create Application for the BMP Constructor, I already write the code in C# but I can't translate it into VB.NET, because its require pointer, and as far as i know, there are no pointer function in vb.net @@ so how I can translate this:

FileStream fs = new FileStream(OJSPathBox.Text, FileMode.Open);
BinaryReader rdr = new BinaryReader(fs);
int width = 555; // its just for example
int height = 555; //its just for example

[code]....

ptr declaration is using Pointer and I throught, there are no unsafe in vb.net, how I can translate to vb.net language?

View 2 Replies

Create New Form Constructor?

Feb 28, 2012

How come when I create new instances of a form and show it, it loads the form twice?[code]...

View 2 Replies

How To Call The Constructor With Parameters

Jun 1, 2010

I am stuck with a problem about generic classes. I am confused how I call the constructor with parameters. [Code] I get error in the starred area of the DBLayer Object. What might be the possible reason? what can I do to fix it? I even want to add New(byval someval as datatype) in IDBObject interface for overloading construction. but it also gives an error? how can i do it? [Code]

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved