我有一个数据网格,我必须在网格的每一行显示带滚动条的日志文本消息
<DataGrid ItemsSource="{Binding LogDetails}" AutoGenerateColumns="False" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto">
<DataGrid.Columns>
<DataGridTextColumn Header="Log " Binding="{Binding Path=LogDetail}" Width="4*" MinWidth="550">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="MaxHeight" Value="300"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource {x:Type DataGridRow}}">
<Setter Property="ToolTip" Value="{Binding Path=ScriptDatasetInfo}" />
<Setter Property="ToolTipService.ShowDuration" Value="60000" />
<Setter Property="MaxHeight" Value="300"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
</Style>
</DataGrid.Resources>
但选择Datarow
时,滚动条不可见