C# 没有背景WPF的ItemsControl
我想问你,是否有可能有ItemsControl没有背景(x:null),不透明 我收集了数据,这些数据在DataTemplate的帮助下显示在ItemsControl中。datatemplate中的一些数据被折叠,我需要能够在itemscontrol后面的另一个控件上单击 以下是我的意思:C# 没有背景WPF的ItemsControl,c#,wpf,itemscontrol,C#,Wpf,Itemscontrol,我想问你,是否有可能有ItemsControl没有背景(x:null),不透明 我收集了数据,这些数据在DataTemplate的帮助下显示在ItemsControl中。datatemplate中的一些数据被折叠,我需要能够在itemscontrol后面的另一个控件上单击 以下是我的意思: <Button x:Name="bt_behind"></Button> <ItemsControl ItemsSource="{Binding ListOfData}" Bac
<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>
我将背景设置为null(也可以尝试itemcontainerstyle),但没有成功。项目后面的On按钮控件仍然不可单击。我认为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>
嗯,正如我所说的,一切都在起作用。固定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>
如果您想让其他人尝试您的代码(在当前形式下甚至无法编译),那么就需要准备。你试过了吗?
ishitestvisible
?背景都是x:Null。。。不知道你的代码出了什么问题。另外,请修复您的XAML问题。如果您希望其他人尝试您的代码(在当前形式下甚至无法编译),那么准备这些代码是值得的。你试过了吗?ishitestvisible
?背景都是x:Null。。。不知道你的代码出了什么问题。另外,请修复您的XAML问题。谢谢回复。我意识到ItemsControl在ScrollViewer中。和ScrollViewer有自定义的HitTesting(背景为空不起作用),所以不能点击按钮。我忘了。我专注于ItemsControl。非常感谢您的测试。感谢您的回复。我意识到ItemsControl在ScrollViewer中。和ScrollViewer有自定义的HitTesting(背景为空不起作用),所以不能点击按钮。我忘了。我专注于ItemsControl。非常感谢您的测试。