首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > CAD教程 >

WPF中ListBox的模板中控件的事情?该如何处理

2012-03-20 
WPF中ListBox的模板中控件的事情?C# codeListBox Margin0 NamelbErrorList ItemContainerStyle{S

WPF中ListBox的模板中控件的事情?

C# code
<ListBox Margin="0" Name="lbErrorList" ItemContainerStyle="{StaticResource ListBoxItemStyle}" ItemsSource="{Binding}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  MouseDoubleClick="lbErrorList_MouseDoubleClick">                            <ListBox.ItemTemplate>                                <DataTemplate>                                    <Border Background="White"  Margin="0" Padding="0"  BorderBrush="#FFACB698" BorderThickness="0,0,0,1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Height="50"  MouseMove="Border_MouseMove"  MouseLeave="Border_MouseLeave">                                        <Grid Margin="0" Height="50" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="grid41" >                                            <Grid.RowDefinitions>                                                <RowDefinition Height="30"/>                                                <RowDefinition Height="30"/>                                            </Grid.RowDefinitions>                                            <Grid.ColumnDefinitions>                                                <ColumnDefinition Width="20"/>                                                <ColumnDefinition Width="100"/>                                                <ColumnDefinition Width="385*"/>                                                <ColumnDefinition Width="100"/>                                            </Grid.ColumnDefinitions>                                            <Image  Width="17" Height="17" Margin="0,0,0,0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Source="{Binding Path=ImageSourceType}"></Image>                                            <Label FontWeight="bold" Grid.Row="0" Grid.Column="1" Width="100"  Content="{Binding Path=DefectName}"></Label>                                            <!--Label  Grid.Row="0" Grid.Column="2" FontSize="12" Foreground="Gray" Content="{Binding Path=Line}"></Label-->                                            <Label Name="txtFile" Grid.Row="0" Width="360"  HorizontalAlignment="Left" Grid.Column="2" FontSize="12" Foreground="Gray" Content="{Binding Path=DisplayFileName}"></Label>                                            <Label Width="100" HorizontalContentAlignment="Center"  Grid.Row="0" Grid.Column="3" FlowDirection="RightToLeft" Foreground="Gray" Content="{Binding Path=Tool}"></Label>                                             <Button Width="20" HorizontalAlignment="Center" VerticalAlignment="Top" Height="20"   Grid.Row="1" Grid.Column="3" Visibility="{Binding IsDisplay}" Content="详细信息">                                            </Button>                                            <Label Margin="0" FontSize="12" Padding="5,0,0,0" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Content="{Binding Path=Detail}"></Label>                                        </Grid>                                    </Border>                                </DataTemplate>                            </ListBox.ItemTemplate>                        </ListBox> 



该ListBox有双击事情,如何解决ListBox模板的中的Button事情?Button点击怎么得到ListBoxItem的哪一个Item被选中了?

[解决办法]
在ListBox中SelectedChanged事件中获取选中项。
[解决办法]
参考

热点排行