Silverlight 1.0 Javascript Intellisense – minor updates (V1.1)

18 באוקטובר 2007

4 תגובות

Based on your feature requests I'm releasing an updated version of the Silverlight Javascript Intellisense.
https://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=intellisense&ReleaseId=6504

image

 

Changes from V1.0 to V1.1:

1. Smaller Javascript files. (roughly 50% in actual file size)

2. Strongly typed Attached properties

3. Enum support.

4. getHost() support

5. exposed the inner Xaml element.

 

 

Smaller Javascript files. (roughly 50% in actual file size)

You've asked for it – you got it.

file sizes for V1.0:
Intellisense.js – 1,275KB
Intellisense.compressed.js – 425KB

image 

file sizes for V1.1:
Intellisense.js – 613KB
Intellisense.compressed.js – 279KB
image

 

Strongly typed Attached properties

In V1.0 you had to have local copies of the DependencyProperty you want to change.

Let's say we want to move "someElement" 100 pixels to the top of the screen by decreasing it's Canvas.Top by 100.

image 

image

image

image

    var CanvasTop = new DependencyProperty("Canvas.Top");

    someElement.setValue(CanvasTop, someElement.getValue(CanvasTop) – 100);

This required you to remember and spell correctly the name of the Attached Properties.
In V1.1 There's static field like constructs you can use.

image

image 

someElement.setValue(Canvas.get_TopProperty(), someElement.getValue(Canvas.get_TopProperty()) – 100);

 

Enum support

In V1.0 you had to initialize all your Enum values and remember them.

Let's say we want to check if a TextBlock has an underline as TextDecorations and if so set it's decorations to none.

image

image

 

    var TextDecorationsUnderline = new TextDecorations("Underline");

    var TextDecorationsNone = new TextDecorations("None");

 

    if (myTextBlock.get_textDecorations().element == TextDecorationsUnderline.element)

        myTextBlock.set_textDecorations(TextDecorationsNone);

 

In V1.1 you can use Enus almost the same way you do in C#.

image

image

image

    if (TextDecorations.is_Underline(myTextBlock.get_textDecorations()))

        myTextBlock.set_textDecorations(TextDecorations.get_None()); 

 

getHost() Support

In V1.0 we had no getHost(), In V1.1 we have getHost with full Intellisense.

image

image

image

image

    someElement.getHost().get_content().set_fullScreen(true);

 

And we can even use createFromXaml with full intellisense.

image

image

    someElement.getHost().get_content().createFromXaml("<TextBlock xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Name=\"tbx2\" />", false);

 

exposed the inner Xaml element

You might want, on occasion to use the actual XAML element that works behind the scenes. In V1.0 you had to use the ".element" extension which you didn't get Intellisense for.

In V1.1 you get Intellisense for this property on every class.

image

 

If you've got any more feature request – I'm open to suggestions.

 

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *

4 תגובות

  1. SmallWhiteBear23 ביוני 2008 ב 8:17

    After I call the command createFromXaml and work fine, I do'nt know how to add the Silverlight object to canvas.

    In the past, I would write the JavaScript statement like below:

    sender.children.add(textBlock);

    Could you give me some suggestions?
    Thank you very much.

    הגב
  2. Justin-Josef Angel [MVP]23 ביוני 2008 ב 22:59

    Hi SmallWhiteBear,

    try:
    sender.children.add(textBlock.get_innerElement());

    as "sender" is not one of our "managed" silverlight javascript objects it won't work with the "managed" silverlight javascript textblock object, just the underlining CLR one. Which you can access through the new getter.

    הגב
  3. SmallWhiteBear24 ביוני 2008 ב 9:58

    Dear Justin

    I try the JavaScript statement "sender.children.add(textBlock.get_innerElement());

    " in my code, but there is nothing happened.

    I have no idea how to solve the problem so I
    post my JavaScript code below:

    function rootCanvas_Loaded(sender, eventArgs)
    {

    var newTextBlock = TextBlock.createFromXaml(sender.getHost());

    newTextBlock.setValue(new DependencyProperty("Canvas.Top"), 500);
    newTextBlock.set_opacity(1);
    newTextBlock.set_text("!234567890");
    newTextBlock.set_height(400);
    newTextBlock.set_width(400);

    sender.children.add(newTextBlock.get_innerElement());

    }

    Could you give me some suggestions?

    Thank you very much.

    הגב
  4. Justin-Josef Angel [MVP]24 ביוני 2008 ב 21:28

    Hi,

    Are you getting any javascript errors?
    Are you sure the javascript eventhandler is getting called?

    Please send the answers to my email at J@JustinAngel.Net.

    הגב