2010-09-10 230 views
1

我有一個只是ASP託管的Silverlight 4對象的頁面。我希望它佔用瀏覽器的全部寬度和高度,但它不是 - 它在一個角落太小。我可以在哪裏調整?如何使Silverlight應用佔用整個瀏覽器寬度/高度?

我是Silverlight的新手。謝謝您的幫助。

編輯:這裏是的.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> 

回答

0

當你創建一個SL應用程序並選擇創建一個Web應用A時,VS模板創建一個.html文件,做你正在尋找什麼對於。關鍵部件是以下

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

而在<form>控制被包裹在一個<div id="silverlightControlHost">元件。

我建議你創建一個快速測試應用程序,選擇選項來創建一個託管的Web應用程序,然後從那裏採取標記。

+0

這個CSS是爲我生成的,但我仍然有這個問題。這可能是我的SL .xaml中的東西嗎? – 2010-09-10 22:33:19

+0

它是SL主機,還是主機中的小標記或標記。快速檢查方法是在預期主控制區域內點擊鼠標並查看是否獲得標準的SL彈出菜單或Web瀏覽器彈出菜單。 – 2010-09-10 22:42:44

+0

我得到SL彈出菜單。所以我的應用程序的內容太小了。 – 2010-09-10 22:44:47

0

檢查你的用戶控件是否被硬編碼了一些大小

相關問題