0

MouseOveronのときにテキストをポップアップするようにコーディングしていToggleButtonます。私もそれを手に入れましたが、本当の問題は、ポップされたテキストが一定に保たれないことです。つまり、ToggleButton. もう1つ、ポップされたテキストはToggleButtonそれ自体に表示されますが、その下にある必要があります。どうすればこれを取り除くことができますか?

これが私のコードの外観です

<ToggleButton x:Name="btn" Width="20" Height="15">
    <Image Source="../Images/flag_orange.ico"/>
</ToggleButton>
<Popup x:Name="popUp" IsOpen="{Binding IsChecked, ElementName=btn, Mode=TwoWay}"
       StaysOpen="False" PlacementTarget="{Binding ElementName=btn}"
       Placement="Bottom" PopupAnimation="Slide" HorizontalOffset="-5"
       VerticalOffset="3">
    <Border Background="DarkGray">
        <TextBox Text="Its a place holder for user notes" x:Name="tbText"/>                         
    </Border>                    
</Popup>
<TextBlock x:Name="tbTextBlock" 
           Visibility="{Binding Path=IsMouseOver,ElementName=btn,Mode=OneWay,
                        Converter={StaticResource BoolToVisibilityConverter}}"
           Text="{Binding ElementName=tbText, Path=Text, Mode=TwoWay}" />
4

1 に答える 1

0

IsHitTestVisible="False"TextBlock で使用します。Mouseover は Textblock によってまだ捕捉されているため、 が表示されたToggleButtonときにマウスは上にありませんTextBlock

ToggleButton の下にある TextBlock を取得するには、 aMargin="0,15,0,0"または aStackPanelを使用してこれらのコントロールを順番に取得します。

<StackPanel>
  <ToggleButton x:Name="btn" Width="20" Height="15">
    <Image Source="../Images/flag_orange.ico"/>
  </ToggleButton>
  <Popup x:Name="popUp" IsOpen="{Binding IsChecked, ElementName=btn, Mode=TwoWay}"
         StaysOpen="False" PlacementTarget="{Binding ElementName=btn}"
         Placement="Bottom" PopupAnimation="Slide" HorizontalOffset="-5"
         VerticalOffset="3">
    <Border Background="DarkGray">
      <TextBox Text="Its a place holder for user notes" x:Name="tbText"/>
    </Border>
  </Popup>
  <TextBlock x:Name="tbTextBlock" 
         IsHitTestVisible="False"
         Visibility="{Binding Path=IsMouseOver,ElementName=btn,Mode=OneWay,
                      Converter={StaticResource BoolToVisibilityConverter}}"
         Text="{Binding ElementName=tbText, Path=Text, Mode=TwoWay}" />
</StackPanel>
于 2013-11-14T12:03:39.847 に答える