簡體   English   中英

無背景WPF的ItemsControl

[英]ItemsControl with none background WPF

我想問你,是否有可能沒有背景(x:null),不透明的ItemsControl。

我已經收集了數據,這些數據在DataTemplate的幫助下顯示在ItemsControl中。 datatemplate中的某些數據已折疊,我需要能夠在itemscontrol后面的另一個控件上單擊。

這是我的意思的示例:

<Button x:Name="bt_behind"></Button>
<ItemsControl ItemsSource="{Binding ListOfData}" Background="{x:Null}">
        <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" Background="{x:Null}"></StackPanel>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate DataType="{x:Type Class:Data}">
                     <Grid Width="100" Background="{x:Null}">
                          <Rectangle x:Name="rec" Fill="Red" Height="100" Visibility="Collapsed">
                     </Grid>
                     <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding IsVisible}" Value="true">
                            <Setter TargeName="rec" Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                     <DataTemplate.Triggers>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
</ItemsControl>

示例,其中item3被部分折疊並標記為區域,其中為空白處

我到處都將背景設置為null(也嘗試使用itemcontainerstyle),但是沒有成功。 ItemsControl后面的“打開”按鈕仍然不可單擊。 我認為ItemsControl具有事件的透明背景,但是可以刪除此背景嗎?

感謝您的任何建議,對不起我的英語:)

-pav-

好吧,正如我所說,一切正常。 固定XAML:

<Grid>
    <Button x:Name="bt_behind" Content="behind" Click="Bt_behind_OnClick"/>
    <ItemsControl ItemsSource="{Binding ListOfData}" Background="{x:Null}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal" Background="{x:Null}"></StackPanel>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate DataType="{x:Type local:Data}">
                <Grid Width="100" Background="{x:Null}">
                    <Rectangle x:Name="rec" Fill="Red" Height="100" Visibility="Collapsed"/>
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding IsVisible}" Value="true">
                        <Setter TargetName="rec" Property="Visibility" Value="Visible"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</Grid>

只是為了測試。

private void Bt_behind_OnClick(object sender, RoutedEventArgs e)
{
    MessageBox.Show("");
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM