Bonjour à tous !

Je vous expose mon problème : j'aimerais faire en sorte que mon application Silverlight se redimentionne automatiquement en fonction du navigateur (jusque là rien de bien compliqué).

Mais : j'aimerai également qu'à l'aide de MinWidth, MinHeigth lorsque je réduits trop la fenêtre, l'application cesse de se réduire et que des ascenceurs apparaissent dans le navigateur.

Pour l'instant j'ai réussi à le faire horizontalement mais pas moyen de le faire verticalement, lorsque je fais la même méthode (que horizontalement), les dimentions de la fenêtre se figent et plus rien n'est dynamique !

Voici les trois parties de mon code :
Tout d'abord mon très puissant XAML :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
<UserControl x:Class="SilverlightApplication3.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <Grid x:Name="LayoutRoot" Background="Red" MinHeight="600" MinWidth="800" Margin="10">
        <StackPanel>
            <TextBlock x:Name="txt1"></TextBlock>
            <TextBlock x:Name="txt2"></TextBlock>
        </StackPanel>
    </Grid>
</UserControl>
Puis viens ma super page ASPX :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
<body style="height:100%;margin:0;">
    <form id="form1" runat="server" style="height:100%;">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div style="position:absolute;z-index:10;top:0;left:0;">
            <asp:Silverlight ID="Xaml1" Windowless="true" runat="server" Source="~/ClientBin/SilverlightApplication3.xap" MinimumVersion="2.0.31005.0" Width="100%" Height="100%" />
        </div>
        <div style="position:absolute;z-index:0;top:0;left:0;">
            <img id="Size" height="10px" width="10px"/>
        </div>
    </form>
</body>
Et enfin le coeur du problème :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
 
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
            this.SizeChanged += new SizeChangedEventHandler(Page_SizeChanged);
        }
 
        void Page_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            //String largeur = HtmlPage.Document.Body.GetAttribute("clientWidth").ToString();
            //String hauteur = HtmlPage.Document.Body.GetAttribute("clientHeight").ToString();
 
            //System.Windows.Browser.HtmlElement size = HtmlPage.Document.GetElementById("Size");
            //System.Windows.Browser.HtmlElement plugin = HtmlPage.Plugin;
            //if (HtmlPage.IsEnabled)
            //{
            //    txt1.Text = largeur;
            //    txt2.Text = hauteur;
            //    if (Double.Parse(largeur) > this.LayoutRoot.MinWidth)
            //    {
            //        size.SetStyleAttribute("width", largeur);
            //        plugin.SetStyleAttribute("width", largeur);
            //    }
            //    else
            //    {
            //        size.SetStyleAttribute("width", this.LayoutRoot.MinWidth.ToString());
            //        plugin.SetStyleAttribute("width", this.LayoutRoot.MinWidth.ToString());
            //    }
            //    //if (Double.Parse(hauteur) > this.LayoutRoot.MinHeight)
            //    //{
            //    //    size.SetStyleAttribute("height", hauteur);
            //    //    plugin.SetStyleAttribute("height", hauteur);
            //    //}
            //    //else
            //    //{
            //    //    size.SetStyleAttribute("height", this.LayoutRoot.MinHeight.ToString());
            //    //    plugin.SetStyleAttribute("height", this.LayoutRoot.MinHeight.ToString());
            //    //}
            //}
 
            String largeur = HtmlPage.Document.Body.GetAttribute("clientWidth").ToString();
            String hauteur = HtmlPage.Document.Body.GetAttribute("clientHeight").ToString();
 
            System.Windows.Browser.HtmlElement plugin = HtmlPage.Plugin;
            if (HtmlPage.IsEnabled)
            {
                txt1.Text = largeur;
                txt2.Text = hauteur;
                if (Double.Parse(largeur) > this.LayoutRoot.MinWidth)
                    plugin.SetStyleAttribute("width", largeur);
                else
                    plugin.SetStyleAttribute("width", this.LayoutRoot.MinWidth.ToString());
                if (Double.Parse(hauteur) > this.LayoutRoot.MinHeight)
                    plugin.SetStyleAttribute("height", hauteur);
                else
                    plugin.SetStyleAttribute("height", this.LayoutRoot.MinHeight.ToString());
            }
 
        }
    }
Le code contient 2 tests :
- celui qui n'est pas commenté fonctionne si l'on commente le second "if else" qui concerne la hauteur et se fige si on le remet
- celui qui est commenté est une autre tentative en simulant une image pour créer les ascenceurs

Si quelqu'un a une idée...

Merci en tout cas à ceux qui m'ont lu jusqu'au bout !!!