For ease of management of a UI that has many elements shown as user controls, I would like my user controls to be inherited from a class of my own. So, in my user control, where there was:
Inherits UserControl
I changed it to
Inherits MyBaseUserControl
And I added a class MyBaseUserControl, which just inherits from UserControl.
It won't run immediately because the autogenerated intermediate file (.g.i.vb) for the UserControl inherits like this:
Inherits Global.Windows.UI.Xaml.Controls.UserControl
.. but if I then edit the intermediate file to
Inherits MyBaseUserControl
it works great, I can effectively identify my own user controls and add properties and methods to them generically, which is exactly what I want to do.
But of course, if I edit the user control in the designer, the intermediate file is regenerated with
Inherits Global.Windows.UI.Xaml.Controls.UserControl
I could manually edit the intermediate file whenever is gets recreated but it seems messy / dangerous.
Is there a way to do this properly?
Thanks
You need to replace the UserControl strings in your XAML with MyBaseUserControl. E.g.
<controls:MyBaseUserControl
x:Class="Sp.MyBaseUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Sp">
...
</controls:MyBaseUserControl>
Where Sp is the namespace that MyBaseUserControl is in.
Related
I am new to AS3.0 and am trying to create a reusable button class. I am working on a quiz game where I have multiple correct and incorrect buttons and instead of copying the same code over and over again I am trying to create a simple way to reuse the code. I am unaware how to do this. I have created various generic button classes and none have worked. I believe the best way would revolve around creating a generic class with a Boolean 'correct' and each button class extends this parent class and sets the correct Boolean true or false. In the parent class there would be a function saying if correct then go to next frame, if !correct go to lose frame. I have tried this but to no avail; any help?
If that's a design question, then no, a button should not know if it's "the correct one" in a given quiz. All logic should be handled by button's parents, whatever type they are. A simple design would do like this: Create a set of buttons with texts, then you addEventListener(MouseEvent.CLICK,someFunction) to each, where someFunction is one for the correct button, and another for wrong-answer buttons.
I'm using Access 2003.
In "References" (Tools > References > Browse...), I've added in "Microsoft Windows Common Controls 6.0 (SP6)" (c:\windows\system32\mscomctl.ocx) and I've created/inserted an instance of the control "Microsoft ListView Control 6.0 (SP6)" on a Form and given the control the Name "MyListView".
I wanted to decorate MyListView with some custom methods so I've created a class ("DecoratedListView") which contains a member field ("lvw").
I want 'lvw' to point/reference MyListView, but I don't know what reference type to use in its declaration. Importantly, I also want to capture lvw's ColumnClick event.
I've tried:
Public WithEvents lvw As Object
Public WithEvents lvw As Control
Public WithEvents lvw As MSComctlLib.ListView.2
and none works when I
set lvw = MyForm.MyListView
Can anyone explain how I should create the reference (lvw) to the existing object (MyListView)?
Access can't really handle that sort of thing.
The OnClick should be available on your MyForm though, but you can't see it in the Event tab in properties. ActiveX Controls are too complicated for that. Instead, go into the code and choose MyListView in the combobox on the top left. You'll then find the extended ActiveX events in the combobox on the top right. One of them is ColumnClick.
Not sure what your full intentions are, but if you want to sort of mimic an isolated DecoratedListView class then create a special form that only includes a ListView control and use it as a subform for other forms. You can refer to the ListView from the parent Form as you would any other subform control object. Parent specific code can be run from the listview subform by checking the me.parent.name object which is basically the parent form. You can even call subform's listview events by changing the default Private Sub to Public Sub.
I can't comment yet, so I'll type it as an answer.
Did you look in View, Object Browser to see what methods and properties are available for that object? You should be able to write what you want using that information, assuming what you want is possible.
I have a basic ASP.Net MVC 3 application which has a number of controllers and a number of actions (and subsequently views)
A common feature of the application is to show a pop-up dialog window for basic user input. One of the key features of this dialog process is a faded mask that gets shown behind the dialog box.
Each of these dialog window controls is in a separate Partial View page.
Now, some view pages may use multiple dialog boxes, and therefore include multiple partial views in them - which as is would mean multiple instances of the "mask" element.
What I am trying to find a solution for is to only need to create one instance of a "mask" element regardless of the number of dialog partial views I include, and then the script in each partial dialog will have access to this element (so basically it just needs to be on the page somewhere)
The only real idea I have come up with so far is to add the "mask" element to the master page (or in the original view page) and this will mean it only gets added once. The problem here is that it will be added even when it is not needed (albeit one small single element)
I can live with this, but I would like to know if there is a better way to handle these kinds of scenarios?
A quick idea that came to mind is some kind of master page inheritance hierarchy, So I may have a DialogMasterPage that inherits from the standard current master page. How does that sound for an approach?
Thanks
To do something like this, where each module can register their need for a certain thing in the master page, you can use HttpContext to store a flag of whether you need to write the mask div, and just set that property in each partial. At the end of the master page, if the flag is set, you can then write the mask div if its set to true.
Obviously to make this cleaner you could wrap it all in an HtmlHelper extension or something.
My initial thought is for you to use something like jQuery UI where it handles the masking for you or if you are using something custom you can load the content for the dialog via ajax then show it in the single dialog on the master page.
Anyone can explain briefly about the [Inspectable] metadata tag. I read and could not understand in live docs.
Please help me when we are going to use the [Inspectable] metadata tag?
Thanks,
ravi
The tag is used with properties to provide code hints for that property and to specify the possible list of values that property can take while using it in mxml. Unlike [Bindable] metadata, this tag doesn't have much effect on the working of the code (other than specifying a default value) - this is used mainly to give directions to Flex Builder regarding how to deal with a particular property.
[Inspectable] metadata tag
Defines an attribute exposed to component users in the attribute hints and Tag inspector of Flex Builder. Also limits allowable values of the property.
For example, the verticalScrollPolicy property of the mx.core.Container class has the following [Inspectable] tag with it.
[Inspectable(category="General", enumeration="off,on,auto", defaultValue="auto")]
public function get verticalScrollPolicy():String
{
return _verticalScrollPolicy;
}
This tells Flex Builder that this property should appear in the 'General' tab (it is 'Common' in my FB) of the Flex Builder's property inspector (open an mxml file, go to the Windows menu and select Flex Properties to open the property inspector - towards the upper side of inspector tab, near its title, you will find buttons to switch to standard view, category view, and alphabetical view). This property can take one of the three values off, on, auto and if none is specified it takes auto as its default value.
I've never used this tag and I believe you too won't be using it much unless you are writing a Flex API to be used by a bigger audience than your colleagues (or if you are a perfectionist).
This tag is useful for when you write your own custom components. While it does not interact with the actual code you write (unlike the [Bindable] tag, mentioned above), it does give the Flexbuilder environment a way of allowing the user to set properties of your component using the UI Designer.
Therefore, the tag is useful if you want to:
Write components that are to be used by other people (make only the publicly accessible properties Inspect'able)
You've written a custom component that is used multiple times in your UI (maybe an extended slider). You then write some Inspect'able getter/setter methods as the public API to your component, and then implement these getter/setter methods to do data validation and implement the internal logic of your component.
You can find more information and examples here. Some good info on writing custom components (using the code behind methodology, which I prefer) can be found here.
Note: When creating exposed properties using [Inspectable], they don't seem to show up in the Flexbuilder Flex-Properties panel (not in Standard view anyway, use Category view or Alphabetical view, instead)
Note: You can find an alternative method of adding public properties to your custom components using MXLM, like this.
I am using fValidator plugin for MooTools, and find necessary to control (depending on user selections) the required class it's used by the plugin.
The class uses a weird formatting which have never used before and for some reason MooTools can recognize it. It probably has something to do with escaping the square brackets and the single quotes.
I tried something like this, among other things, but no luck yet.
This is the code:
$("checkbox3").removeClass("fValidate\\[\\'required\\'\\]");
Are you looking to remove/add required elements to the validation? As it picks up all the elements at first you'd have to unregister them, remove the class and then re-register them.
Unfortunately it doesn't seem to have an unregister method by default so you'd have to monkey patch the script to add this, also as the register method doesn't parse class names you'd have to add a new method that does this. Finally you'd have to make the event that is added to the field for the blur in register a binding that you could re-use the binding to remove that event
It's quite an involved patch/rewrite of fValidator to achieve this and if possible I would look at another validation script -- such as form check which does allow you to un-register and re-register fields at run time (among a lot of other improvements).