2011-05-13 63 views
1

此問題僅發生在vista和xp上。正在發生的事情是,如果有一個文本框有很多文本,並且部分在屏幕之外,並且您點擊它,那麼wpf會將其滾動到視圖中並突出顯示文本。在Windows 7中,它不會將其滾動到視圖中。我正在使用.net 4,並試圖清除文本框收到的焦點,鍵盤焦點和鼠標捕捉事件的選擇,但滾動似乎發生在那些之後。我包含了一些我正在談論的屏幕截圖以及一個演示問題的測試應用程序。wpf隨機高亮顯示vista/xp上的文本

點擊任何東西,在下一屏前拍我所做的就是點擊在線6 Before

點擊在線6可以看到,因爲它滾動文本框眼簾的一切都突出了。 after

攝製:

/// <summary> 
/// Interaction logic for MainWindow.xaml 
/// </summary> 
public partial class MainWindow : Window 
{ 
    public MainWindow() 
    { 
     InitializeComponent(); 
     for (int i = 1; i < 1000; i++) 
     { 
      textBox3.AppendText(string.Format("line {0}\r\n", i)); 
     } 
    } 
} 

<Window x:Class="WpfApplication1.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="MainWindow" Height="350" Width="525" MaxHeight="350" MaxWidth="525"> 
<Grid> 
    <ScrollViewer> 
     <Grid> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="100"></RowDefinition> 
       <RowDefinition Height="auto"></RowDefinition> 
       <RowDefinition Height="*"></RowDefinition> 
      </Grid.RowDefinitions> 
      <TextBox Grid.Row="0" Text="this is some text"></TextBox> 
      <TextBox Grid.Row="1" Text="this is some text"></TextBox> 
      <TextBox Grid.Row="2" ScrollViewer.CanContentScroll="True" 
      ScrollViewer.VerticalScrollBarVisibility="Auto" AcceptsReturn="True" 
      x:Name="textBox3"></TextBox> 
     </Grid> 
    </ScrollViewer>   
    </Grid> 
</Window> 

回答

0

從微軟原來,這是.NET 3.5的一個已知問題,他們固定在.NET 4.0中。他們沒有解決問題。