Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyPopup : Popup
- {
- static MyPopup()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(MyPopup), new FrameworkPropertyMetadata(typeof(MyPopup)));
- }
- }
- <Style x:Key="MyPopupStyle" TargetType="{x:Type local:MyPopup}">
- <Setter Property="Placement" Value="MousePoint" />
- <Setter Property="Child">
- <Setter.Value>
- <Border
- Width="100"
- Height="100"
- Background="HotPink" />
- </Setter.Value>
- </Setter>
- <Setter Property="IsOpen" Value="{Binding RelativeSource={RelativeSource Self}, Path=PlacementTarget.IsMouseOver, Mode=OneWay}" />
- </Style>
- <Window.Resources>
- <DataTemplate x:Key="Foo">
- <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
- <TextBlock x:Name="TextBlock" Text="Hover over" />
- <wpfApp1:MyPopup PlacementTarget="{Binding ElementName=TextBlock}" />
- </StackPanel>
- </DataTemplate>
- </Window.Resources>
- <ListBox ItemTemplate="{StaticResource Foo}" ItemsSource="{Binding MyList}" />
- public partial class MainWindow
- {
- public MainWindow()
- {
- InitializeComponent();
- MyList = new List<string>{"Dan","John","Test"};
- DataContext = this;
- }
- public List<string> MyList { get; }
- }
Add Comment
Please, Sign In to add comment