none
1.SL怎么填充整个网页;2.怎么Binding子类属性, RRS feed

  • 问题

  • 1.SL怎么填充整个网页
    index.html

    <title>
     
    </title>
     
        
        <style type="text/css">
        html, body {
    	    height: 100%;
    	    overflow: auto;
        }
        body {
    	    padding: 0;
    	    margin: 0;
        }
        #silverlightControlHost {
    	    height: 100%;
    	    text-align:center;
        }
        </style>
     
        <script type="text/javascript">
            function onSilverlightError(sender, args) {
                var appSource = "";
                if (sender != null & sender != 0) {
                  appSource = sender.getHost().Source;
                }
     
                var errorType = args.ErrorType;
                var iErrorCode = args.ErrorCode;
     
                if (errorType == "ImageError" || errorType == "MediaError") {
                  return;
                }
     
                var errMsg = "Silverlight 应用程序中未处理的错误 " +  appSource + "\n" ;
     
                errMsg += "代码: "+ iErrorCode + "    \n";
                errMsg += "类别: " + errorType + "       \n";
                errMsg += "消息: " + args.ErrorMessage + "     \n";
     
                if (errorType == "ParserError") {
                    errMsg += "文件: " + args.xamlFile + "     \n";
                    errMsg += "行: " + args.lineNumber + "     \n";
                    errMsg += "位置: " + args.charPosition + "     \n";
                }
                else if (errorType == "RuntimeError") {           
                    if (args.lineNumber != 0) {
                        errMsg += "行: " + args.lineNumber + "     \n";
                        errMsg += "位置: " +  args.charPosition + "     \n";
                    }
                    errMsg += "方法名称: " + args.methodName + "     \n";
                }
     
                throw new Error(errMsg);
            }
        </script>
    </head>
    <body>
        <form name="aspnetForm" method="post" action="default.aspx" id="aspnetForm">
    <div>
    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
    <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTY1NDU2MTA1MmRkdqhB91FJlXoQyBerJpMUSQO7/7U=" />
    </div>
     
    <script type="text/javascript"> 
    //<![CDATA[
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
        theForm = document.aspnetForm;
    }
    function __doPostBack(eventTarget, eventArgument) {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
            theForm.__EVENTTARGET.value = eventTarget;
            theForm.__EVENTARGUMENT.value = eventArgument;
            theForm.submit();
        }
    }
    //]]>
    </script>
     
     
    <script src="/WebResource.axd?d=NLhrytK2LhLpFMJ79D6oEQ2&amp;t=633911959998392095" type="text/javascript"></script>
     
     
    <script src="/ScriptResource.axd?d=d35QVRdG0S5o4qqlA5hkkMvNVMu7l2JAuBfpz3N9SvLb3hqrCYSO2crwCFwvQCmntuGCHIvLK4JLNQ6f0Q7vJo_0JWS9cPmTj7MFtrPNNIE1&amp;t=ffffffffebf3533f" type="text/javascript"></script>
    <script type="text/javascript"> 
    //<![CDATA[
    if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
    //]]>
    </script>
     
    <script src="/ScriptResource.axd?d=d35QVRdG0S5o4qqlA5hkkMvNVMu7l2JAuBfpz3N9SvLb3hqrCYSO2crwCFwvQCmnpB9lhzpe3CvXWf3-xGShcoBMQ7bTRUjfYSjz09mE8uZ-giKaK7byfWLPnHrMeOEO0&amp;t=ffffffffebf3533f" type="text/javascript"></script>
        <div>
            <script type="text/javascript"> 
    //<![CDATA[
    Sys.WebForms.PageRequestManager._initialize('ctl00$ScriptManagerMain', document.getElementById('aspnetForm'));
    Sys.WebForms.PageRequestManager.getInstance()._updateControls([], [], [], 90);
    //]]>
    </script>
     
            
       <div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
            width="100%" height="100%">
            <param name="source" value="ClientBin/NewExperience.xap" />
            <param name="onerror" value="onSilverlightError" />
            <param name="background" value="white" />
            <param name="minRuntimeVersion" value="3.0.40624.0" />
            <param name="autoUpgrade" value="true" />
            <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration: none;">
                <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="获取 Microsoft Silverlight"
                    style="border-style: none" />
            </a>
        </object>
        <iframe id="_sl_historyFrame" style='visibility: hidden; height: 0; width: 0; border: 0px'>
        </iframe>
    </div>
            
     
        </div>
        
     
    <script type="text/javascript"> 
    //<![CDATA[
    Sys.Application.initialize();
    //]]>
    </script>
    </form>
    </body>
    </html>
    




    MainPage.xaml

    <UserControl x:Class="JHSoft.Homepage.Threshold.UI.NewExperience.MainPage"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 xmlns:uriMapper="clr-namespace:System.Windows.Navigation;assembly=System.Windows.Controls.Navigation">

        <Grid x:Name="LayoutRoot"
              Style="{StaticResource LayoutRootGridStyle}">

            <Border x:Name="ContentBorder"
                    Style="{StaticResource ContentBorderStyle}">

                <navigation:Frame x:Name="ContentFrame"
                                  Style="{StaticResource ContentFrameStyle}"
                                  Source="/Home"
                                  Navigated="ContentFrame_Navigated"
                                  NavigationFailed="ContentFrame_NavigationFailed">
                    <navigation:Frame.UriMapper>
                        <uriMapper:UriMapper>
                            <uriMapper:UriMapping Uri=""
                                                  MappedUri="/Views/Home.xaml" />
                            <uriMapper:UriMapping Uri="/{pageName}"
                                                  MappedUri="/Views/{pageName}.xaml" />
                        </uriMapper:UriMapper>
                    </navigation:Frame.UriMapper>
                </navigation:Frame>
            </Border>

            <Grid x:Name="NavigationGrid"
                  Style="{StaticResource NavigationGridStyle}">

                <Border x:Name="BrandingBorder"
                        Style="{StaticResource BrandingBorderStyle}">
                    <StackPanel x:Name="BrandingStackPanel"
                                Style="{StaticResource BrandingStackPanelStyle}">

                        <ContentControl Style="{StaticResource LogoIcon}" />
                        <TextBlock x:Name="ApplicationNameTextBlock"
                                   Style="{StaticResource ApplicationNameStyle}"
                                   Text="应用程序名称" />

                    </StackPanel>
                </Border>

                <Border x:Name="LinksBorder"
                        Style="{StaticResource LinksBorderStyle}">
                    <StackPanel x:Name="LinksStackPanel"
                                Style="{StaticResource LinksStackPanelStyle}">

                        <HyperlinkButton x:Name="LinkHome"
                                         Style="{StaticResource LinkStyle}"
                                         NavigateUri="/Home"
                                         TargetName="ContentFrame"
                                         Content="主页" />

                        <Rectangle x:Name="DividerHome"
                                   Style="{StaticResource DividerStyle}" />

                        <HyperlinkButton x:Name="LinkAbout"
                                         Style="{StaticResource LinkStyle}"
                                         NavigateUri="/About"
                                         TargetName="ContentFrame"
                                         Content="关于" />

                    </StackPanel>
                </Border>

            </Grid>

        </Grid>

    </UserControl>


    About.xaml
    <navigation:Page x:Class="JHSoft.Homepage.Threshold.UI.NewExperience.About"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                     xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                     mc:Ignorable="d"
                     d:DesignWidth="640"
                     d:DesignHeight="480"
                     Title="关于"
                     Style="{StaticResource PageStyle}">

        <Grid x:Name="LayoutRoot">
            <ScrollViewer x:Name="PageScrollViewer"
                          Style="{StaticResource PageScrollViewerStyle}">

                <StackPanel x:Name="ContentStackPanel">

                    <TextBlock x:Name="HeaderText"
                               Style="{StaticResource HeaderTextStyle}"
                               Text="关于" />
                    <TextBlock x:Name="ContentText"
                               Style="{StaticResource ContentTextStyle}"
                               Text="关于页内容" />

                </StackPanel>

            </ScrollViewer>
        </Grid>

    </navigation:Page>

    在About.xaml网页里点击右键为什么只有上面一小部分显示SL右键菜单,而大部分都是html网页的菜单?也就是说网页没有被SL完全填充.

    2.怎么Binding子类属性,
    IList<MiddleWare.BlogInfo> blogs;
    this.grdMain.ItemsSource = blogs;

    BlogInfo有个属性Account,是AccountInfo类型,  怎么像<TextBlock Text="[{Binding Account.UserName}]" />这样绑定?


    谢谢您的解答.


    民主是人类社会的普遍价值观.(Democratic is a common value of the human society)
    2009年12月22日 4:02

答案

  • 没啥特殊方法, 就是新建了项目就好了.我原来用了MasterPage,里面生成的div会包含silverlightControlHost的div,不使用MP就好了.
    谢谢你的回答
    民主是人类社会的普遍价值观.(Democratic is a common value of the human society)
    2009年12月22日 6:41

全部回复

  • 1.去掉DesignWidth和DesingHeight试一下?
    2.grdMain是ItemsControl么?如果有ItemTemplate则指定ItemTemplate

    比如:

    <ItemsControl.ItemTemplate>
      <DataTemplate>
        <TextBlock Text="{Binding Account.UserName}" />
      </DataTemplate>
    </ItemsControl.ItemTemplate>

    就可以了

    EaranSE 2.0:中国最早上线&中国最好的Silverlight企业应用
    2009年12月22日 4:32
  • 1.去掉DesignWidth和DesingHeight试一下?
    2.grdMain是ItemsControl么?如果有ItemTemplate则指定ItemTemplate

    比如:

    <ItemsControl.ItemTemplate>
      <DataTemplate>
        <TextBlock Text="{Binding Account.UserName}" />
      </DataTemplate>
    </ItemsControl.ItemTemplate>

    就可以了

    EaranSE 2.0:中国最早上线&中国最好的Silverlight企业应用

    绑定可以了,但是填充的去掉也不行的
    民主是人类社会的普遍价值观.(Democratic is a common value of the human society)
    2009年12月22日 5:09
  • 自己搞定了.
    谢谢回答
    民主是人类社会的普遍价值观.(Democratic is a common value of the human society)
    2009年12月22日 5:32
  • 搞定了就把方法分享出来嘛!


    EaranSE 2.0:中国最早上线&中国最好的Silverlight企业应用
    2009年12月22日 6:37
  • 没啥特殊方法, 就是新建了项目就好了.我原来用了MasterPage,里面生成的div会包含silverlightControlHost的div,不使用MP就好了.
    谢谢你的回答
    民主是人类社会的普遍价值观.(Democratic is a common value of the human society)
    2009年12月22日 6:41
  • 这个样子。。。了了!


    EaranSE 2.0:中国最早上线&中国最好的Silverlight企业应用
    2009年12月22日 6:42