【发布时间】:2011-08-04 21:03:26
【问题描述】:
我正在开发一个 Windows Phone 应用程序。
我有一个带有以下 XAML 代码的用户控件:
<UserControl x:Class="XXXXXXX.Views.SignIn.FacebookControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="768" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
<!--ContentPanel. Colocar aquí el contenido adicional-->
<Grid x:Name="ContentPanel" Margin="12,0,12,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock
Grid.Row="1"
Height="30"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Visibility="Visible"
Margin="10"
Name="LoadingText"
Text="{Binding Path=AppResources.BrowserNavigating, Source={StaticResource LocalizedStrings}}"/>
<phone:WebBrowser
Grid.Row="0"
Name="FacebookLoginBrowser"
IsScriptEnabled="True"
Height="607"
VerticalAlignment="Top"
HorizontalAlignment="Stretch"
Margin="0,10"
Navigated="FacebookLoginBrowser_Navigated"
Loaded="FacebookLoginBrowser_Loaded"
Navigating="FacebookLoginBrowser_Navigating"/>
</Grid>
</Grid>
</UserControl>
我知道这个:
WebBrowser 有一个左边距,大于它的右边距。
更新
这就是我嵌入用户控件的方式:
facebookControl = new FacebookControl();
facebookControl.SetValue(Grid.RowSpanProperty, 2);
facebookControl.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
facebookControl.VerticalAlignment = System.Windows.VerticalAlignment.Top;
facebookControl.Margin = new Thickness(0);
facebookControl.Height = 768;
facebookControl.Width = 480;
ContentPanel.Children.Add(facebookControl);
这是 ContentPanel 的定义:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
...
我该如何解决这个问题?
【问题讨论】:
-
您的
Margin="0,10"行可能与此有关。您是否尝试将其设置为单个数字以使所有边距都相同? -
@johnhforrest:我已经改成 0 了,我也遇到了同样的问题。
标签: layout windows-phone-7 webbrowser-control margin