silverlight   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了解决Silverlight插件过长浏览器滚动条不出现的问题大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

在aspx页面中只能静态的设置Silverlight插件的大小,但是插件的高度是时常变化的,而且如果变化很大,比如从几百到几千px,那总不能一开始就设一个很大的高度吧?但问题是Silverlight并不能根据自己的高度将页面撑开,而只是clip了而已,这就带来了一个问题,如何才能在适当的时候才让浏览器的滚动条出现呢?这个问题倒是困扰了一部分的朋友的,因此来测试和总结一下。   首先建一个新工程,我
@H_675_13@@H_618_14@
@H_618_14@

在aspx页面中只能静态的设置Silverlight插件的大小,但是插件的高度是时常变化的,而且如果变化很大,比如从几百到几千px,那总不能一开始就设一个很大的高度吧?但问题是Silverlight并不能根据自己的高度将页面撑开,而只是clip了而已,这就带来了一个问题,如何才能在适当的时候才让浏览器的滚动条出现呢?这个问题倒是困扰了一部分的朋友的,因此来测试和总结一下。

  首先建一个新工程,我这里建的是“Silverlight Navigation Application”,也就是带导航模板的,因此在模板的home.xaml页面中放一个很长的矩形,如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<Grid x:Name="LayoutRoot">
        <!--<ScrollViewer x:Name="PageScrollViewer" Style="{Staticresource PageScrollViewerStylE}">-->
            <StackPanel x:Name="ContentStackPanel">
                <TextBlock x:Name="HeaderText" Style="{Staticresource HeaderTextStylE}" 
                                   Text="Home"/>

                <TextBlock x:Name="ContentText" Style="{Staticresource ContentTextStylE}" 
                                   Text="Home page content"/>
                <Rectangle Width="200" Height="1000" Fill="Red"/>
            </StackPanel>
        <!--</ScrollViewer>-->
</Grid>

 

 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
public @H_570_144@mainPage()
{

            InitializeComponent();

            this.Layoutupdated += new EventHandler(MainPage_Layoutupdated);
        }

        private double _minimalHeight = 300;

        void @H_570_144@mainPage_Layoutupdated(object sender,EventArgs E)

        {

            Size size = this.LayoutRoot.DesiredSize;

            if (size.Height < _minimalHeight)

            {

                size.Height = _minimalHeight;

            }

            String heighTinPixel = String.Format("{0}px",size.Height);

            String containerElementId = "silverLightcontrolHost";

            HtmlElement element = HtmlPage.Document.GetElementById(containerElementId);

            element.SetStyleAttribute("height",heighTinPixel);
}
 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
public @H_570_144@mainPage()
{

            InitializeComponent();

            this.Layoutupdated += new EventHandler(MainPage_Layoutupdated);
        }

        private double _minimalHeight = 300;

        void @H_570_144@mainPage_Layoutupdated(object sender,heighTinPixel);
}

 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
public @H_570_144@mainPage()
{

            InitializeComponent();

            this.Layoutupdated += new EventHandler(MainPage_Layoutupdated);
        }

        private double _minimalHeight = 300;

        void @H_570_144@mainPage_Layoutupdated(object sender,heighTinPixel);
}
@H_618_14@

大佬总结

以上是大佬教程为你收集整理的解决Silverlight插件过长浏览器滚动条不出现的问题全部内容,希望文章能够帮你解决解决Silverlight插件过长浏览器滚动条不出现的问题所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:silverlight出现插件浏览器滚动条解决过长问题
猜你在找的silverlight相关文章
其他相关热搜词更多
phpJavaPython程序员load如何string使用参数jquery开发安装listlinuxiosandroid工具javascriptcap