WPF Popup绑定目标控件上下左右位置

Popup的 PlacementTarget属性为绑定某个控件  Placement为上下左右方位,效果如下

TextBox

<TextBox x:Name="txt_Code" Grid.Column="1"
         Width="200"
         Height="28"
         FontSize="18"
         HorizontalAlignment="Left"
         Opacity="1"                             
         Margin="20,5,20,5"
         MaxLength="7"                                                                                    
         input:InputMethod.IsInputMethodEnabled="False"
         VerticalContentAlignment="Center"
         >
        <TextBox.Resources>
           <Style TargetType="{x:Type Border}">
              <Setter Property="CornerRadius" Value="2"/>
              <Setter Property="BorderBrush" Value="#c1d0dc"/>
           </Style>
        </TextBox.Resources>
</TextBox>

Popup

Popup x:Name="Popup_tick"                           
                               StaysOpen="False"                              
                               AllowsTransparency="True"   
                               IsOpen="False"
                               PlacementTarget="{Binding ElementName=txt_Code}"
                               Placement="Right"
                               >
                        <Path  Data="M 0,100  Q 35,140  54,190 Q 100,45  168,0 S 90,40  50,150 Q 40,136 0,100 Z "
                               Fill="#89BF04" 
                               Stretch="Fill"    
                               Margin="2,0,0,0"
                               VerticalAlignment="Bottom"
                               HorizontalAlignment="Center"
                               Height="28"
                               Width="30"
                               />
                    </Popup>
原文地址:https://www.cnblogs.com/CityOfThousandFires/p/13280692.html