2

基本上,我有一个 DataTemplate 来定义 ItemsControl 中的项目,并且我想在单击项目时在项目上方弹出一个对话气泡。到目前为止,我的尝试导致我的装饰器出现在 DataTemplate 内并被该 DataTemplate 的边界剪裁而不是在它之上。我一直在使用一个漂亮的装饰器控件,可以在这里找到:http: //www.codeproject.com/KB/WPF/adornedcontrol.aspx

我的 XAML 看起来像这样:

    <DataTemplate x:Key="TrackActivityDetailTemplate">
        <ac:AdornedControl HorizontalAlignment="Center" VerticalAlignment="Center" VerticalAdornerPlacement="Outside" >
            <ac:AdornedControl.AdornerContent>
                <TextBlock Foreground="Red" Text="HEY!!!!" />
            </ac:AdornedControl.AdornerContent>
            <Rectangle Name="btn" Height="35" Width="2" Fill="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ItemsControl}}}" >
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseLeftButtonDown">
                    <cmd:EventToCommand Command="{Binding Path=SelectActivityCommand}" PassEventArgsToCommand="True"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Rectangle>
        </ac:AdornedControl>
    </DataTemplate>

有什么想法吗?我试图对装饰者做的事情甚至可能吗?

4

1 回答 1

1

对的,这是可能的。我要尝试的第一件事是在导致剪辑的元素上设置 ClipToBounds=false。

但是,这并不总是有效,在这些情况下,您可以将其包裹在画布中并“浮动”画布。这个技巧在这里描述:http: //drwpf.com/blog/2007/12/28/cliptoboundsmaybe/

于 2011-01-05T21:19:35.920 回答