如何做WRAP PANLE 不可点击 只能点击里面控件
求大神告知哪个属性能做到这种效果
问题如下
想不显示 WRAPPANLE 只显示 里面控件 且 WRAPPANLE 不可点击
大牛 解决一下
项目要上线 很丑 很着急
<ListBox Height="300" HorizontalAlignment="Left" Margin="0,0,0,0" Name="listBox1" VerticalAlignment="Top"
Width="400" Background="Transparent" ItemsSource="{Binding dsFood}" ScrollViewer.CanContentScroll="True"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible" BorderBrush="White"
>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel ItemHeight="100" ItemWidth="110" Visibility="Visible" Focusable="False">
</WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid HorizontalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="0" ></RowDefinition>
<RowDefinition Height="50" ></RowDefinition>
<RowDefinition Height="10"></RowDefinition>
</Grid.RowDefinitions>
<Button Content="{Binding Name}" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="10pt" Grid.Row="1" Width="105" Height="40" Click="btnSaleOrder_Click" CommandParameter="{Binding RelativeSource ={RelativeSource Self}}"/>
<TextBlock Text="{Binding Price}" IsEnabled="False" Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="8pt" TextWrapping="Wrap" />
<TextBlock Name="ItemID" Text="{Binding ItemID}" Visibility="Hidden" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="8pt" TextWrapping="Wrap" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
干嘛用wrap panel 用listbox 不就好了 container是wrappanel。
不可点击设置个属性不能focuse.
focusable false试了一下 还是不是我想要的效果
已经嵌套了 LISTBOX
@愤青愤青: hittest =false 试试。 看界面你这做的还可以啊,为何纠结于wrappanel的点击问题。
@Darren.Dai: hittest =false 好使是好使 里面按钮也点击不了……
@愤青愤青: 你是指不希望点蓝色的区域出现效果? 只能点按钮? 如果这样的话用一个itemscontrol 就好了 就没有选中效果了。
<ItemsControl Name="listBox1" Width="400" Height="300" HorizontalAlignment="Left" Margin="0,0,0,0" VerticalAlignment="Top" Background="Transparent" BorderBrush="White" ItemsSource="{Binding dsFood}" ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Focusable="False" ItemHeight="100" ItemWidth="110" Visibility="Visible"> </WrapPanel> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Grid HorizontalAlignment="Center"> <Grid.RowDefinitions> <RowDefinition Height="0"/> <RowDefinition Height="50"/> <RowDefinition Height="10"/> </Grid.RowDefinitions> <Button Width="105" Height="40" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" CommandParameter="{Binding RelativeSource ={RelativeSource Self}}" Content="{Binding Name}" FontSize="10pt"/> <TextBlock Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="8pt" IsEnabled="False" Text="{Binding Price}" TextWrapping="Wrap"/> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>