I am trying to create a new Control (Let us for now forget about UserControl or CustomControl).
I open a Windows phone Application project in vs2010 and then add a new item Windows phone Control Library and then I use it in my phone application.
Everything works fine. Now if I want to create a windows phone control to be used in another application how should I be going about it? New application means a separate new solution.
Phone Application1 -> Have my own control inside the solution and hence I am able to use it.
How can I use this same control in another new solution?
I am not sure if this has been answered before. Does any solution already exist?
Cavet:
I tried creating a new Windows phone Class Library in a vs2010 instance but it didn't work because it didn't had a xaml form. When I tried to manually include it and write the logic it build successfully but now even if I include the dll of this project I don't get the control in the toolbox. This process does not make much sense to me as I am creating a class library and not a control but still wanted to give it a try.
To show controls from your assembly in the toolbox, you should do design-time assembly. You can look at these articles for the beginning:
Link2
Link1
It's not easy and perhaps you can live without that if your control assembly is not a commercial product. To use any control from other assembly in application:
add project reference to your control assembly
include xmlns namespace attribute corresponding to your assembly to any page of your application. Just start typing 'xmlns=' near other xmlns definitions in the page header and VS intellisense will show you the list of available namespaces. Choose the needed one and then set namespace alias to use on the page. It should look something like xmlns:myNamespace="clr-namespace:MyAssembly.Namespace.;assembly=MyAssembly"
insert control from your assembly into page using xaml editor
now you should be able to see your control in xaml designer and edit its properties from the property grid
.
I am not sure if the above mentioned method would solve the case, because as far as I have seen it is not possible to create a Windows Phone Control Library in VS2010. So this is what I did..
Created a Windows Phone Control Library and write my own custom control.
Build the project.
Back to Vs2010, added the reference to the control in the app in which I wish to use.
As simple as that. I don't know why it was initially a little bit confusing (perhaps I would have got confused with the binding and stuff). Anyways its quite simple though. Thank you for the reply.
Related
I am currently working with a 3rd party ActiveX Control (an editor for topographical data distributed by Cadcorp SIS). I have to do some fairly complex stuff with it in a VB.NET (framework 4) program and am finding that the API that comes with the control is quite limited.
As of now I have made a custom control which houses the control and acts as a wrapper for it to allow me to extend the API, which works fine, but What I would really like to do it give the control more events so that I can monitor what is going on with the data more closely.
I'm not sure how to go about doing this though...
I tried inheriting from the control and I can extend it just fine, but I can't figure out how to reuse it after that. Is there some way I can inherit the control and get it to appear in the toolbox so I can just drop it onto a form? Or do I have to load it programatically? If so, how can I do it?
Any pointers, examples, tutorials or alternative ideas as to how to do this kind of thing would be welcome.
If you are not seeing your control class in toolbox it doesn’t mean that you can’t use it just modify code from your form's designer to use your inherited class
Or
You can drag-and-drop your assembly (dll) from Windows Explorer to the
toolbox in VS.NET. Or you can right click on the toolbox in VS.NET and
choose Add/Remove items. Is this what you are looking for?
Also
<ToolBoxItem(True), ToolboxBitmap("MyNamespace.MyClass.bmp")> _
Public Class MyClass
I'm trying to use Webkit-Sharp to implement a simple HTML browser in my application. I'm using Microsoft Visual C# Express Edition with the hopes of eventually moving the code over to Linux under Mono.
My first step was to add references to all of the Webkit dll files.
Next, I went and added the WebKitBrowser controls to the toolbox in the standard way and dropped a WebKitBrowser control on my form (specifically, on a TabPage.
I added the needed using statements of using WebKit; and using Webkit.Interop; to my declarations. My webkitBrowser control is called myBrowserControl. As I understand it, I should be able to do things like
myBrowserControl.Navigate('http://www.google.com');
and the browser should take me to Google's homepage. But, for some reason, it doesn't understand what WebkitBrowser is. In my Form Designer code, I have the following line:
private WebKit.WebKitBrowser myBrowserControl;
and I am being told that WebKitBrowser doesn't exist in the WebKit namespace and I may be missing a reference to an assembly. But it doesn't seem like I am. Can anyone help me figure this out? I know I'm doing something simple wrong but I can't figure out what.
Thanks
Just posting in case someone else finds this.
Were you trying to drop a WebKit gtk control into a Winforms project? That doesn't work. You might possibly be able to do this if you're using gtk on windows, although I've heard no one has had any success getting webkit-sharp working in windows.
You could actually use the winforms browser control in windows, since there is a (now unsupported) winforms port in mono.
I have been trying to customize a webbrowser control in wp7. All I need to do is to add a border property(I think it is already available in webbrowser but I have to make it mandatory when I make it as a control) and want to add a few extra event handlers and make it as a control so that it can be used later in different projects.
I tried reading through materials in msdn for writing control template and it all revolves around writing a few xaml code and attaching it with codebehind to make it work. What I don't understand is how do I learn xaml? or in other words where is the reference for all the tags that msdn talks about in xaml? Itseems to be huge and I am not sure how to go about it. The tutorial in msdn straight away divulges into xaml code and I am totally confused..
So now all I am trying to do is this,
create a control in Expression Blend (Windows Phone Control Library) that would create a class (MyCustomControl) that inherits
from CustomControl base class.
Now in xaml I am adding a webbrowser control and adding four event handlers (mouseup,down etc.,).
I build this control in blend and add the corresponding dll in VS2010.
And now once I try to add this control to my wp7 phone application it says "Cannot create an instance of MyCustomControl"..
These were further links that I referenced in creating one,
Windowsphone - Creating a custom control
Windowsphone - Control Template.
UserControl vs Custom Control
Creating a new control by creating ControlTemplate
Any further help would be great.
There is no definitive list of 'elements' you can add to your XAML. The reason for this is that the XAML parser can create any class which is a UIElement based on the XML you provide. So the elements available to you depend on the assemblies present in your project. Read teh MSDN XAML Overview for details
For a list of controls that are present by default, take a look at the System.Windows.Controls namespace (I think this link is not for your version of Silverlight, it might be best to use the Object Browser to look at the assemblies in your project).
For your problem, where you want to add a border to a WebBrowser control. I would recommend creating a UserControl as per this tutorial.
I have Downloaded the RCM Library from http://www.codeproject.com/KB/cs/RCM.aspx but i don't know how to add the controls that it provides to c# toolbox or how to use the custom form it provides.Guys Plz Help me Out.
One of the solutions can be derive every control you need with your own class inside your project . After rebuild you SHOULD see them in toolbox.
how do I enable visual styles when my project is a class library and it's being loaded into a program that does not have Application.EnableVisualStyles() set. I have been struggling with this for 2 days now. This is in C# (I've seen some examples for older C++ and some things that may work for VB, but nothing has been clearly laid out for C# and if it's even possible).
I have tried to run Application.EnableVisualStyles() from my Class Library before creating any controls, but it seems that needs to be done before an Application.Run() is done, and I don't have control when an Application.Run() is called since this is going into a 3rd party app as a plugin (VMware's Virtual Infrastructure Client).
I have tried to create a manifest file and after compiling the class library I link in the manifest file to my ProgressBar.dll with:
mt.exe -manifest ProgressBar.dll.manifest -outputresource:ProgressBar.dll;2
Except this doesn't work. If I make a dummy Application that uses my ProgressBar class library and link the manifest to that Application's exe, then the visual styles come up (basically it's doing the long way of specifying the Manifest file in the Project Properties, Application section).
Right now my buttons look ugly, but the biggest thing that is irritating is that the ProgressBar control doesn't work in Marquee style. I'm very soon going to have to resort to making my own Marquee-style ProgressBar or just throwing in an animated GIF in it's place. With regards to the buttons, I guess I can start using Infragistics buttons in order to get a more consistent result.
Please and thanks as always!
How can you be sure that there are no controls created yet when you call Application.EnableVisualStyles? Created does not necessarily mean that the controls are also visible on a form.
Since you are working with a closed 3rd-party component I would invest my time rather in creating my own controls if the look and feel is that important.
You'll have to use the OpenThemeData Win32 api in your control:
MSDN: Using Windows XP Visual Styles