我有 silverlight web 应用程序。我在子窗口中显示日志信息。子窗口包含一个文本框控件。我设置了 ScrollViewer.VerticalScrollBarVisibility="Auto" 但没有显示垂直滚动条。请帮助我。
XAML
<controls:ChildWindow x:Class="LogPopUpWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
Width="600" Height="400"
Title="" HasCloseButton="False">
<Grid x:Name="LayoutRoot" Margin="2">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBox x:Name="LogEvents" IsReadOnly="True" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Visible"></TextBox>
<Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
</Grid>
C#
public void RefreshLogs(string message = "")
{
StringBuilder text = new StringBuilder();
if (string.IsNullOrEmpty(message))
{
if (Logger.GetLogs() != null)
{
Logger.GetLogs().ForEach(b =>
{
text.AppendFormat("{2}{0}: {1}{2}", b.UserTargetOperation, b.UserEventDate.ToString(), Environment.NewLine);
foreach (KeyValuePair<string, string> pair in b.Parameters)
{
text.AppendFormat(" {0} : {1}{2}", pair.Key, pair.Value, Environment.NewLine);
}
});
}
LogEvents.Text = text.ToString();
}
else
{
LogEvents.Text = message;
LogEvents.TextWrapping = TextWrapping.Wrap;
}
}
按钮处理程序编码器
private void ShowLogLink_Click(object sender, System.Windows.RoutedEventArgs e)
{
///Logger.GetLogs();
///
LogPopUpWindow win = new LogPopUpWindow();
win.RefreshLogs();
win.Show();
}