有時,當我使用文本框時,無法一直向下滾動以查看最後一個單詞。Silverlight 4文本框不顯示全部內容
我已經包含一個具有相同內容但寬度不同的三個文本框的示例。左邊的一個不顯示所有的單詞。
選擇它移動到文本框的末尾,然後按'ctrl'+'end'。當我爲左側的文本框('_tb1')執行此操作時,我看不到光標,也看不到最後一個單詞。看起來光標和文字在文本框的「下方」。我可以標記並複製未顯示的文字。最後一個字應該是「si +」,見下面的代碼。我已驗證文本框的「文本」屬性包含所有文本。
迄今爲止,只有當我使用'TextWrapping ='Wrap''和某些寬度時纔會發生這種情況。
有關如何解決它的任何建議?
<UserControl x:Class="Silverlight4TextBoxProblem.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid Width="500" Height="150">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBox Name="_tb1" Grid.Column="0" TextWrapping="Wrap"
FontFamily="Arial" FontSize="12"
VerticalScrollBarVisibility="Visible"
Width="100"/>
<TextBox Name="_tb2" Grid.Column="1" TextWrapping="Wrap"
FontFamily="Arial" FontSize="12"
VerticalScrollBarVisibility="Visible"
Width="75"/>
<TextBox Name="_tb3" Grid.Column="2" TextWrapping="Wrap"
FontFamily="Arial" FontSize="12"
VerticalScrollBarVisibility="Visible"
Width="150"/>
<Button Grid.Column="3" Click="ButtonClick" Content="Assert _tb1"/>
</Grid>
</UserControl>
代碼隱藏
public partial class MainPage : UserControl
{
private readonly string ErrorText = @"Lorem ipsum dolor sit amet+++," + Environment.NewLine
+ "consectetur adipisicing elit, sed do eiusmod" + Environment.NewLine
+ "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam," + Environment.NewLine
+ "quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo" + Environment.NewLine
+ "consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse" + Environment.NewLine
+ "cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non" + Environment.NewLine
+ "proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem" + Environment.NewLine
+ "ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor" + Environment.NewLine
+ "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis" + Environment.NewLine
+ "nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." + Environment.NewLine
+ "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu" + Environment.NewLine
+ "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in" + Environment.NewLine
+ "culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit" + Environment.NewLine
+ "amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore" + Environment.NewLine
+ "et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation" + Environment.NewLine
+ "ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor" + Environment.NewLine
+ "in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla" + Environment.NewLine
+ "pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui" + Environment.NewLine
+ "officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet," + Environment.NewLine
+ "consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et" + Environment.NewLine
+ "dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco" + Environment.NewLine
+ "laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in" + Environment.NewLine
+ "reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." + Environment.NewLine
+ "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia" + Environment.NewLine
+ "deserunt mollit anim id est laborum. Lorem ipsum dolor si+";
public MainPage()
{
InitializeComponent();
_tb1.Text = ErrorText;
_tb2.Text = ErrorText;
_tb3.Text = ErrorText;
}
private void ButtonClick(object sender, RoutedEventArgs e)
{
MessageBox.Show(_tb1.Text.Last().ToString());
}
}
我相信這傢伙有同樣的問題:https://connect.microsoft.com/VisualStudio/feedback/details/549531/silverlight4-textbox-show-multiple-line-text-wrong 我雖然無法重現他的錯誤,但我使用XP和他的Windows 7. – 2011-01-25 09:38:06