简体   繁体   中英

Customize control/ Writing Control Templates in wp7

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,

  1. create a control in Expression Blend (Windows Phone Control Library) that would create a class (MyCustomControl) that inherits from CustomControl base class.

  2. Now in xaml I am adding a webbrowser control and adding four event handlers (mouseup,down etc.,).

  3. I build this control in blend and add the corresponding dll in VS2010.

  4. 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM