English 中文(简体)
ZOrder with Canvas within the List
原标题:ZOrder of Expander with Canvas inside of List

我有一个清单,其中载有一些控制,包括<代码>Expander。 在扩大小组内还有一份名单,我想把这份清单放在外。 这里简单地重提:

<Page.Resources>
    <x:Array x:Key="array1" Type="sys:String">
        <sys:String>item 1</sys:String>
        <sys:String>item 2</sys:String>
        <sys:String>item 3</sys:String>
    </x:Array>
    <DataTemplate x:Key="buttonTemplate">
        <Button Content="{Binding}"/>
    </DataTemplate>
    <DataTemplate x:Key="expanderItem">
        <StackPanel>
            <Expander Header="Options">
                <Canvas>
                    <StackPanel Panel.ZIndex="999" Background="Red">
                        <Label>A1</Label>
                        <Label>A2</Label>
                        <Label>A3</Label>
                        <Label>A4</Label>
                    </StackPanel>
                </Canvas>
            </Expander>
            <Label BorderBrush="Black" BorderThickness="2" Content="{Binding}"/>
        </StackPanel>
    </DataTemplate>
</Page.Resources>
<Grid>
    <ListBox ItemsSource="{StaticResource array1}" ItemTemplate="{StaticResource expanderItem}"/>
</Grid>

当<代码>Expander 开放时,内部标签的数值与同一<代码>DataTemplate的标签和清单中后来的内容相同。 我已尝试将<条码> 查询编码> 。

如果加上以下风格:

<Style TargetType="{x:Type Expander}">
    <Style.Triggers>
        <Trigger Property="IsExpanded" Value="True">
            <Setter Property="Panel.ZIndex" Value="999"/>
        </Trigger>
    </Style.Triggers>
</Style>

它将适当超支SAME清单项目的项目,但仍然与以后清单项目的内容相混合。

(我怀疑这是一个相当明显的布局问题,但我未能找到这一问题)。)

最佳回答

您可尝试根据清单中项目索引,在数据模板中填写ZIndex的转换器。 有趣的是,随着项目增加/删除,确保一切更新都正确无误。

你们是否需要扩大者独立于布局?

问题回答

暂无回答




相关问题
WPF convert 2d mouse click into 3d space

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

WPF: writing smoke tests using ViewModels

I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

How do WPF Markup Extensions raise compile errors?

Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签