Skip to main content

Microsoft Silverlight

Answered Question What version of Silverlight do I have? How to emulate CSS and Layers? WPF v. Silverlight neutrality? Pan and Zoom?RSS Feed

(0)

siegfried_heintze
siegfrie...

Member

Member

5 points

19 Posts

What version of Silverlight do I have? How to emulate CSS and Layers? WPF v. Silverlight neutrality? Pan and Zoom?

1)  Why does not http://silverlight.net/quickstarts/silverlight10/text.aspx work for my IE 7 browser? If I change the first line to <Canvas xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
it works. Do I need to upgrade something? I also tried to run the examples at http://quickstarts.asp.net/futures/silverlight/xaml.aspx and they said I needed to close all my browsers, uninstall my current version of silverlight and install SILVERLIGHT 1.1 ALPHA REFRESH. I don't want to install an older version!

The version of Silverlight I have was installed automagically installed (no prompting) when I ran the snowboarder example at http://www.xaml.net/

(2) I just want to display some text at a certain location. Which should I use: TextBlock or Label? Both seem to work. They seem redundant. I don't understand the strange syntax Label uses (the Margin attribute) to specify the coordinates.

(3) In HTML/CSS and SVG, I can specify a style block where I define a class. Can I do the same in XAML? It seems very verbose to have to specify

  FontSize="10" FontFamily="Georgia" FontStyle="Italic" FontWeight="Bold" FontStretch="Expanded"

  over and over again for each TextBlock.

(4) How do I implement the notion of dynamic layers? In HTML I defined a css class called "ru" for russian, another css class "en" for english and "tch" for traditional chinese. Then using javascript I change the visibility to hidden (or display to none) for all but one class so I only display text in one language at a time. How do I do that in xaml?

 (5) How do I implement <a href="page2">page</a> in xaml? Why does not visual studio have link and other HTML like controls in the the toolbox toobar that I can drag and drop into my web page?

(6) What tags should I begin with? Visual studio generates a <Page...> tag but (as I mentiond above) canvas seems to work too. Can I achieve WPF v. silverlight neutrality (i.e., use the identical XAML for both) if I use a <canvas...> tag? I think the answer is yes (I guess I should try it). If so, why does visual studio use the different tags of Windows v. Page?

(7) How do I implement pan and zoom? I did a live search and found a few links. I was hoping to find a simple explanation I could look at easily and instead found references to the swordfish and other libraries and not a single live example I could try. In SVG pan and zoom is just three lines of javascript code. Is it really that complicated in XAML that I need to download a whole library?

(8) Is there a counterpart to the SVG viewbox tag that allows me to specify the physical size of the viewable area in inches or cm and the range of world coordinates to use within that area?

(9) Is here an XSD for xaml?

Thanks,
Siegfried

 

Bill Reiss
Bill Reiss

Contributor

Contributor

4836 points

917 Posts

Silverlight MVP
Answered Question

Re: What version of Silverlight do I have? How to emulate CSS and Layers? WPF v. Silverlight neutrality? Pan and Zoom?

The xaml.net snowboarder example doesn't install silverlight, it installs a xaml viewer. I would assume that you don't have the latest version of Silverlight, you can get it here: http://www.microsoft.com/silverlight/resources/install.aspx?v=2.0


Bill Reiss, Coauthor of Hello! Silverlight 3
My blog (rss feed)

grava
grava

Member

Member

87 points

18 Posts

Answered Question

Re: What version of Silverlight do I have? How to emulate CSS and Layers? WPF v. Silverlight neutrality? Pan and Zoom?

 

siegfried_heintze:
(3) In HTML/CSS and SVG, I can specify a style block where I define a class. Can I do the same in XAML? It seems very verbose to have to specify

  FontSize="10" FontFamily="Georgia" FontStyle="Italic" FontWeight="Bold" FontStretch="Expanded"

  over and over again for each TextBlock.

 

Sure you can, please have a look at:

http://silverlight.net/learn/tutorials/stylestemplates.aspx

HTH

Gianluca Gravina

codeblock
codeblock

Contributor

Contributor

4060 points

716 Posts

Silverlight MVP
Answered Question

Re: What version of Silverlight do I have? How to emulate CSS and Layers? WPF v. Silverlight neutrality? Pan and Zoom?

uhm... a couple of questions here.... :) 

siegfried_heintze:

1)  Why does not http://silverlight.net/quickstarts/silverlight10/text.aspx work for my IE 7 browser? If I change the first line to <Canvas xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
it works. Do I need to upgrade something? I also tried to run the examples at http://quickstarts.asp.net/futures/silverlight/xaml.aspx and they said I needed to close all my browsers, uninstall my current version of silverlight and install SILVERLIGHT 1.1 ALPHA REFRESH. I don't want to install an older version!

The version of Silverlight I have was installed automagically installed (no prompting) when I ran the snowboarder example at http://www.xaml.net/

you __need__ to uninstall version 1.1 because it is an old "alpha" of Silverlight. Now Silverlight is 2.0 Beta 2. Download it here: http://www.microsoft.com/silverlight/resources/install.aspx?v=2.0

siegfried_heintze:

(2) I just want to display some text at a certain location. Which should I use: TextBlock or Label? Both seem to work. They seem redundant. I don't understand the strange syntax Label uses (the Margin attribute) to specify the coordinates.

There is no Label control in Silverlight. You have to use Textblock. To position elements on the scene you must learn about Layout Controls. If you need absolute positioning you must use <canvas> anc Canvas.Top / Canvas.Left attached properties

siegfried_heintze:


(3) In HTML/CSS and SVG, I can specify a style block where I define a class. Can I do the same in XAML? It seems very verbose to have to specify

  FontSize="10" FontFamily="Georgia" FontStyle="Italic" FontWeight="Bold" FontStretch="Expanded"

  over and over again for each TextBlock.

Someone has already answer. You need to learn about styles in XAML.

siegfried_heintze:


(4) How do I implement the notion of dynamic layers? In HTML I defined a css class called "ru" for russian, another css class "en" for english and "tch" for traditional chinese. Then using javascript I change the visibility to hidden (or display to none) for all but one class so I only display text in one language at a time. How do I do that in xaml?

This is a strange kind of localization for html pages.... using Silverlight you can download localized contents from the server and use them to populate the interface. Or you may use resource files.

siegfried_heintze:

 (5) How do I implement <a href="page2">page</a> in xaml? Why does not visual studio have link and other HTML like controls in the the toolbox toobar that I can drag and drop into my web page?

you have the <HyperlinkButton> element...

For editing the XAML visually you must install Expression Blend 2.5

http://www.microsoft.com/downloads/details.aspx?familyid=32A3E916-E681-4955-BC9F-CFBA49273C7C

siegfried_heintze:

(6) What tags should I begin with? Visual studio generates a <Page...> tag but (as I mentiond above) canvas seems to work too. Can I achieve WPF v. silverlight neutrality (i.e., use the identical XAML for both) if I use a <canvas...> tag? I think the answer is yes (I guess I should try it). If so, why does visual studio use the different tags of Windows v. Page?

The XAML used by Silverlight is a subset of WPF. Many features of WPF simply does not exists in Silverlight (e.g. 3D). Silverlight has an extended set of controls and not all this controls works with WPF (Datagrid, Calendar, etc)

siegfried_heintze:

(7) How do I implement pan and zoom? I did a live search and found a few links. I was hoping to find a simple explanation I could look at easily and instead found references to the swordfish and other libraries and not a single live example I could try. In SVG pan and zoom is just three lines of javascript code. Is it really that complicated in XAML that I need to download a whole library?

Pan is not a big problem. Simply move (or Translate transform) the canvas that include all the elements you need to pan. Zooming is a bit more complex. You have to apply a Scale transform to the canvas.

siegfried_heintze:

(8) Is there a counterpart to the SVG viewbox tag that allows me to specify the physical size of the viewable area in inches or cm and the range of world coordinates to use within that area?

uhm... no.

siegfried_heintze:

(9) Is here an XSD for xaml?

yes you may find it in the schemas directory of Visual Studio after you have installed the Silverlight Tools.

C:\Program Files\Microsoft Visual Studio 9.0\Xml\Schemas\wpfe.xsd

siegfried_heintze:


Thanks,
Siegfried

bye

If this answers your question, please "mark it as answer"

--
Andrea Boschin
MVP Silverlight & Silverlight Insider
, Me on Twitter

siegfried_heintze
siegfrie...

Member

Member

5 points

19 Posts

Re: Re: What version of Silverlight do I have? How to emulate CSS and Layers? WPF v. Silverlight neutrality? Pan and Zoom?

Wow! I finally found the correct forum! Thanks guys. I'm still ingesting all your good information.

 In regard to my "strange form of localization". I'm not really trying to implement localization. Most applications don't need to allow the users to dynamically change languages (my application does, however) because most users pick a language and stick with it.

 So I have been reading http://silverlight.net/learn/tutorials/stylestemplates.aspx. This is good.

 So in javascript/css/html or javascript/svg I can do this:

document.styleSheets[0].Rules[1].style.visibility = "hidden";
document.styleSheets[0].Rules[0].style.visibility = "visible";

(1) Can I dynamically alter a style like this in silverlight/WPF?

(2) If I "download localized contents from the server and use them to populate the interface" can I dynamcially repopulate the interface with different localized contents? If I use resources can I dynamically load a new resource on demand and see it instantly manifest?

Thanks much!

Siegfried

 

codeblock
codeblock

Contributor

Contributor

4060 points

716 Posts

Silverlight MVP

Re: Re: What version of Silverlight do I have? How to emulate CSS and Layers? WPF v. Silverlight neutrality? Pan and Zoom?

siegfried_heintze:

document.styleSheets[0].Rules[1].style.visibility = "hidden";
document.styleSheets[0].Rules[0].style.visibility = "visible";

(1) Can I dynamically alter a style like this in silverlight/WPF?

it is not the Style you have to alter. You may use the Visibility property of the element setting it to Visible or Collapsed

siegfried_heintze:

(2) If I "download localized contents from the server and use them to populate the interface" can I dynamcially repopulate the interface with different localized contents? If I use resources can I dynamically load a new resource on demand and see it instantly manifest?

yes you can.

 

If this answers your question, please "mark it as answer"

--
Andrea Boschin
MVP Silverlight & Silverlight Insider
, Me on Twitter

slyi
slyi

Participant

Participant

818 points

251 Posts

Re: Re: What version of Silverlight do I have? How to emulate CSS and Layers? WPF v. Silverlight neutrality? Pan and Zoom?

 (2) See http://wpf-e.spaces.live.com/ for some localization pointers

siegfried_heintze
siegfrie...

Member

Member

5 points

19 Posts

Re: Re: What version of Silverlight do I have? How to emulate CSS and Layers? WPF v. Silverlight neutrality? Pan and Zoom?

 Andrea:

andrea:

 it is not the Style you have to alter. You may use the Visibility property of the element setting it to Visible or Collapsed

 

Does this mean I cannot change a set of objects dynamically (their visibility, for example) and collectively and I must loop thru and change the style of each object to be collapsed? And to do this, I have to use an array or list?

 

Thanks,

Siegfried

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities