Skip to main content

Microsoft Silverlight

Answered Question Silverlight Form Resize.RSS Feed

(0)

klmelaya
klmelaya

Member

Member

2 points

10 Posts

Silverlight Form Resize.

Hi,

I have changed my system resolution, In case of silverlight form is not resized.

by

Elayaraja

Tim Dawson
Tim Dawson

Participant

Participant

1140 points

218 Posts

Re: Silverlight Form Resize.

Silverlight content is displayed in a browser; what does your system resolution have to do with it? I would not expect anything to change in your Silverlight application when the system resolution is changed.


Microsoft MVP
Controls for Silverlight, WPF and Windows Forms at http://www.divelements.co.uk

klmelaya
klmelaya

Member

Member

2 points

10 Posts

Re: Silverlight Form Resize.

hi,

my system resolution is 1600. The design is developed in 1024 pixels.

The resize problem is occured when after publishing...

i think change silverlight html or aspx.

plz help..

thanks

by

Elayaraja

Mog Liang - MSFT
Mog Lian...

All-Star

All-Star

16023 points

1,553 Posts

Answered Question

Re: Silverlight Form Resize.

In silverlight, if you don't set UserControl's width/height property, the silverlight control will fill the place which you offered in html pages, and Grid as well, it will fill the parent's space automaticly. XAML like this: 

<UserControl x:Class="SL3_test1.SilverlightControl2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    >
    <Grid x:Name="LayoutRoot" Background="White">
    ......
    </Grid>
</UserControl> 
If the UserControl be set with fix size, it also can be resized in aspx page by setting asp.net control "Silverlight" 's ScaleMode=Stretch or Zoom
 <asp:Silverlight ID="Silverlight1" runat="server" Source="~/ClientBin/SL3_test1.xap" MinimumVersion="3.0.40307.0" ScaleMode=Zoom Width="100%" Height="100%" />

Mog Liang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

btcrawler
btcrawler

Member

Member

2 points

2 Posts

Re: Silverlight Form Resize.

I'm having problems with the resizing, i'm using the Visifire chart tool, i'm sending the chart from the .cs file with something like this: LayoutRoot.Children.Add(chart)

Here is my code:

 <UserControl x:Class="ResizeTest_1.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <Grid x:Name="LayoutRoot" Background="White" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">      
    </Grid>
</UserControl>

 

<html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;">
<head runat="server">
    <title>ResizeTest_1</title>
</head>
<body style="height:100%;">
    <form id="form1" runat="server" style="height:100%;">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div style="height:100%;">            
            <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/ResizeTest_1.xap"
             Version="2.0" Enabled="true" EnableHtmlAccess="true"
             Visible="true" Width="100%" Height="100%">
            </asp:Silverlight>
        </div>     
    </form>
</body>
</html>

I need to add the style="height:100%;" property to each tag, otherwise the chart doesn't resize correctly. I also tried with the ScaleMode="Stretch" inside the div tag but i got a blank page when using this property.

see_sana_here
see_sana...

Member

Member

2 points

1 Posts

Re: Silverlight Form Resize.

Hi btcrawler...

Add a scrollviewer for the grid and set the properties HorizontalScrollBarVisibility="Auto"   VerticalScrollBarVisibility="Auto"

 

Here is my code:

<UserControl x:Class="ResizeTest_1.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
     <ScrollViewer HorizontalScrollBarVisibility="Auto"   VerticalScrollBarVisibility="Auto">
    <Grid x:Name="LayoutRoot" Background="White" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" >  

 <Grid.RowDefinitions  >
            <RowDefinition     ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"></RowDefinition>
            <RowDefinition  ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" ></RowDefinition>
        </Grid.RowDefinitions>
     
        <Grid.ColumnDefinitions >
            <ColumnDefinition   ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"></ColumnDefinition>
            <ColumnDefinition   ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"></ColumnDefinition>
            <ColumnDefinition   ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"></ColumnDefinition>
        </Grid.ColumnDefinitions>     
    </Grid>
</ScrollViewer>
</UserControl>

 

 

Place the contols in grid.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities