简体   繁体   English

如何使Silverlight应用程序占用整个浏览器的宽度/高度?

[英]How to make a Silverlight app take up the entire browser width/height?

I have a page that is just an ASP-hosted Silverlight 4 object. 我有一个页面,它只是一个由ASP托管的Silverlight 4对象。 I would like it to take up the full width and height of the browser, but it is not - it is too small, in a corner. 我希望它占据浏览器的整个宽度和高度,但事实并非如此-它太小了,在角落里。 Where can I adjust this? 我在哪里可以调整?

I'm new to Silverlight. 我是Silverlight的新手。 Thanks for the help. 谢谢您的帮助。

Edit: Here is the .xaml: 编辑:这是.xaml:

<UserControl x:Class="ExpenseCalc_SilverLight.MainPage"
    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"
    mc:Ignorable="d"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <Grid x:Name="LayoutRoot" Background="White" Height="Auto" Width="Auto">
        <Rectangle Height="441" HorizontalAlignment="Left" Margin="-21,-14,0,0" Name="rectangle1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="583" Fill="#FFA86E6E" Opacity="1" />
        <TextBlock Height="114" HorizontalAlignment="Left" Margin="13,14,0,0" Name="textBlock1" Text="Current Expenses" VerticalAlignment="Top" Width="424" FontSize="28" />

        <sdk:DataGrid AutoGenerateColumns="True" Height="78" HorizontalAlignment="Left" Margin="13,60,0,0" Name="CurrentExpensesGrid" VerticalAlignment="Top" Width="494" />

        <TextBlock FontSize="15" Height="114" HorizontalAlignment="Left" Margin="12,158,0,0" Name="textBlock2" Text="Add New" VerticalAlignment="Top" Width="424" />
        <sdk:Label Height="18" HorizontalAlignment="Left" Margin="13,187,0,0" Name="label1" VerticalAlignment="Top" Width="48" Content="Name" />
        <TextBox Text="{Binding Name, Mode=TwoWay}" Height="23" HorizontalAlignment="Left" Margin="13,205,0,0" Name="NameTextBox" VerticalAlignment="Top" Width="74" />
        <sdk:Label Content="Date" Height="18" HorizontalAlignment="Left" Margin="97,187,0,0" Name="label2" VerticalAlignment="Top" Width="48" />
        <sdk:Label Content="Cost" Height="18" HorizontalAlignment="Left" Margin="203,187,0,0" Name="label3" VerticalAlignment="Top" Width="48" />
        <sdk:Label Content="Who paid" Height="18" HorizontalAlignment="Left" Margin="257,187,0,0" Name="label4" VerticalAlignment="Top" Width="63" />

        <TextBox Text="{Binding Cost, Mode=TwoWay, ValidatesOnExceptions=True}" Height="23" HorizontalAlignment="Left" Margin="203,205,0,0" Name="CostTextBox" VerticalAlignment="Top" Width="48" />

        <sdk:Label Content="Who owes" Height="18" HorizontalAlignment="Left" Margin="337,187,0,0" Name="label5" VerticalAlignment="Top" Width="63" />
        <sdk:AutoCompleteBox Height="23" HorizontalAlignment="Left" Margin="337,205,0,0" Name="WhoOwesInput" VerticalAlignment="Top" Width="74" ValueMemberBinding="{Binding}" LostFocus="WhoOwesInput_LostFocus" />
        <sdk:Label Content="Receipt" Height="18" HorizontalAlignment="Left" Margin="417,187,0,0" Name="label6" VerticalAlignment="Top" Width="63" />
        <Button Content="Add" Height="30" HorizontalAlignment="Left" Margin="337,154,0,0" Name="AddButton" VerticalAlignment="Top" Width="155" FontSize="15" Click="AddButton_Click" />
        <sdk:DatePicker Text="{Binding Date, Mode=TwoWay}" Height="23" HorizontalAlignment="Left" Margin="97,205,0,0" Name="datePicker1" VerticalAlignment="Top" Width="100" />
        <ComboBox Height="23" HorizontalAlignment="Left" Margin="257,205,0,0" Name="WhoPaidComboBox" VerticalAlignment="Top" Width="74" />
        <ListBox Height="100" HorizontalAlignment="Left" Margin="337,232,0,0" Name="WhoOwesListBox" VerticalAlignment="Top" Width="74" KeyDown="WhoOwesListBox_KeyDown" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="418,205,0,0" Name="textBox1" VerticalAlignment="Top" Width="74" />
    </Grid>
</UserControl>

When you create a SL application and choose to create a Web Applicatio, the VS template creates a .html file that does exactly what you are looking for. 当您创建SL应用程序并选择创建Web应用程序时,VS模板会创建一个.html文件,该文件完全可以满足您的需求。 The key parts are the following 关键部分如下

<style type="text/css">
html, body {
    height: 100%;
    overflow: auto;
}
body {
    padding: 0;
    margin: 0;
}
#silverlightControlHost {
    height: 100%;
    text-align:center;
}
</style>

And in the <form> the control is wrapped in a <div id="silverlightControlHost"> element. <form> ,控件包装在<div id="silverlightControlHost">元素中。

I would suggest you create a quick test app, select the option to create a hosting web application and then take the markup from there. 我建议您创建一个快速测试应用程序,选择创建托管Web应用程序的选项,然后从那里获取标记。

检查您的用户控件是否被硬编码到某个大小

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使按钮占据整个包含形式? - How can I make a button take up its entire containing form? 如何使ListView的项目占据所有可用高度? - How can i make a ListView's items take up all the available height? 如何在Silverlight OOB应用程序中设置最小宽度和高度? - How to set minimum width and height in a silverlight OOB application? 如何制作一个可预滚动的标签控件,以便我可以添加大量文本框而无需占用整个屏幕的窗体 - how to make a prescrollable tab control so i can add in tons of text boxes without having the form not take up the entire screen 如何正确设置silverlight应用程序进行调试? - How to properly set up a silverlight app for debugging? 如何使我的 MAUI 应用程序的 window 固定,因此无法调整大小或设置最小高度/宽度? - How can I make the window of my MAUI app fixed, so not resizable or set a minimum height/width? 如何使部分在Dynamics CRM表单编辑器中占据整个空间 - How to make a section take entire space in Dynamics CRM form editor 如何在UWP应用中为椭圆的宽度和高度设置动画 - How to animate the width and height of an ellipse in an UWP app xamarin:我的masterDetailPage占据整个屏幕高度 - xamarin : My masterDetailPage take the entire screen height 动态更新Silverlight子元素的高度和宽度 - Updating the height and width of a Silverlight child element dynamically
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM