2016-05-30 14 views
2

テキストボックスのフォーカスが失われたときに、選択したテキストのハイライトがテキストボックスに表示されないようにするにはどうすればよいですか? WPFの次の行はUWP - テキストボックスのフォーカスが外れているときにテキストボックスのハイライトを表示

textBox1.IsInactiveSelectionHighlightEnabled = true; 

と同じですが、UWPと同等のものは何ですか?

答えて

0

私が知っているように、UWPには同等のものはありません。可能な回避策の1つは、画像を使用して選択範囲を強調表示し続けることです。ここでのサンプルコードは、次のとおりです。

XAML:

<Border BorderThickness="2" BorderBrush="{ThemeResource TextBoxBorderThemeBrush}" Height="164" Width="684"> 
    <TextBox x:Name="textBox" TextWrapping="Wrap" Text="TextBox" BorderThickness="0,0,0,0"/> 
</Border> 

C#の:フォーカスで

private async void TextBox_SelectionChanged(object sender, RoutedEventArgs e) 
    { 
     // clear background    
     textBox.Background = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 255)); ; 

     // render image 
     RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(); 
     await renderTargetBitmap.RenderAsync(textBox); 

     // set background 
     textBox.Background = new ImageBrush() 
     { 
      ImageSource = renderTargetBitmap 
     }; 
    } 

: 焦点のenter image description here

ない: enter image description here

P.S. SelectionChangedイベントの背景を更新していますが、実際にはそのイベントでイメージを作成し、LostFocusイベントでのみ更新できます。より効率的でなければなりません。

関連する問題