0

我有一个列表框,它的列表源是“结果”对象的列表。结果类如下所示:

public class Result
{
    public string GUID { get; set; }
    public string __invalid_name__I { get; set; }
    public string FN { get; set; }
    public string DOB { get; set; }
    public string SEX { get; set; }
    public string SN { get; set; }
    public string __invalid_name__U { get; set; }
    public string TYPE { get; set; }        

    //Gender icon path associated with result
    public string SexIcon { get; set; }
}

这就是我的列表框在 xaml 代码中的样子:

<ListBox 
            Height="517" 
            HorizontalAlignment="Left" 
            Margin="12,84,0,0" 
            Name="searchList" 
            VerticalAlignment="Top" 
            Width="438" 
            SelectionChanged="SearchList_SelectedEvent">

            <!-- What each listbox item will look like -->
            <ListBox.ItemTemplate>
                <DataTemplate>                        
                    <StackPanel Orientation="Horizontal">

                        <Image Source="{Binding Path=Sex, Converter={StaticResource SexToSourceConverter}}" Visibility="Visible" />                            
                        <StackPanel>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Name="FirstName" Text="{Binding FN}" FontSize="28" Margin="0,0,10,0"/>
                                <TextBlock Name="LastName" Text="{Binding SN}" FontSize="28" />
                            </StackPanel>
                            <TextBlock Text="{Binding DOB}" FontSize="24" />
                            <!-- Line Stroke="#FF04863C" StrokeThickness="3" X1="100" Y1="100" X2="300" Y2="100" / -->
                        </StackPanel>
                    </StackPanel>                            
                </DataTemplate>
            </ListBox.ItemTemplate>

        </ListBox>

所以我的问题是,(以及我真正苦苦挣扎的问题)是如何获取所选项目(基本上是结果对象)的 GUID 属性的值?

4

1 回答 1

1

(searchList.SelectedItem 作为结果).GUID

于 2012-07-10T12:35:59.787 回答