Windows Phone開發之 ListBox控制項

來源:互聯網
上載者:User
前台頁面代碼:
<!--資料列表開始-->                <ScrollViewer  HorizontalScrollBarVisibility="Auto" BorderBrush="White" BorderThickness="1" Margin="0,120,0,0">                <StackPanel Height="450">                    <!--<Border BorderBrush="Gray" BorderThickness="1">-->                    <Grid Margin="5,0,0,2">                        <Grid.ColumnDefinitions>                            <ColumnDefinition MinWidth="130" Width="130"  MaxWidth="150" />                            <ColumnDefinition MinWidth="150" Width="150"  MaxWidth="200"/>                            <ColumnDefinition MinWidth="150" Width="150"  MaxWidth="200"/>                            <ColumnDefinition MinWidth="200" Width="250"  MaxWidth="400"/>                        </Grid.ColumnDefinitions>                        <Border BorderBrush="Gray" BorderThickness="1" Grid.Column="0">                            <TextBlock Grid.Column="0" HorizontalAlignment="Center" Text="客戶名稱"></TextBlock>                        </Border>                        <Border BorderBrush="Gray" BorderThickness="1" Grid.Column="1">                            <TextBlock Grid.Column="1"  HorizontalAlignment="Center" Text="固定電話"></TextBlock>                        </Border>                        <Border BorderBrush="Gray" BorderThickness="1" Grid.Column="2">                            <TextBlock Grid.Column="2" HorizontalAlignment="Center"  Text="行動電話"></TextBlock>                        </Border>                        <Border BorderBrush="Gray" BorderThickness="1" Grid.Column="3">                            <TextBlock Grid.Column="3" HorizontalAlignment="Center"  Text="地址"></TextBlock>                        </Border>                    </Grid>                    <!--</Border>-->                    <ListBox x:Name="listbox1" Height="415" ItemsSource="{Binding}" Margin="0,0,0,0"  VerticalAlignment="Top" SelectionChanged="listbox1_SelectionChanged" IsSynchronizedWithCurrentItem="{x:Null}">                        <ListBox.ItemTemplate>                            <DataTemplate>                                <Grid Height="30" Margin="5,0,0,2">                                    <Grid.ColumnDefinitions>                                        <ColumnDefinition MinWidth="130" Width="130" MaxWidth="150"/>                                        <ColumnDefinition MinWidth="150" Width="150"  MaxWidth="200" />                                        <ColumnDefinition MinWidth="150" Width="150"  MaxWidth="200"/>                                        <ColumnDefinition MinWidth="200" Width="250" MaxWidth="400" />                                    </Grid.ColumnDefinitions>                                    <Border BorderBrush="Gray" BorderThickness="1" Grid.Column="0">                                        <TextBlock Grid.Column="0" Text="{Binding KHMC}"></TextBlock>                                    </Border>                                    <Border BorderBrush="Gray" BorderThickness="1"  Grid.Column="1">                                        <HyperlinkButton Grid.Column="1"  HorizontalContentAlignment="Left" Tag="{Binding KHMC}"  Content="{Binding GDDH}" Click="HyperlinkButton_Click_CALLGDDH"></HyperlinkButton>                                    </Border>                                    <Border BorderBrush="Gray" BorderThickness="1"  Grid.Column="2">                                        <HyperlinkButton Grid.Column="2" HorizontalContentAlignment="Left" Tag="{Binding KHMC}" Content="{Binding YDDH}" Click="HyperlinkButton_Click_CALLYDDH"></HyperlinkButton>                                    </Border>                                    <Border BorderBrush="Gray" BorderThickness="1"  Grid.Column="3">                                        <TextBlock Grid.Column="3" Text="{Binding DZ}"></TextBlock>                                    </Border>                                </Grid>                            </DataTemplate>                        </ListBox.ItemTemplate>                    </ListBox>                </StackPanel>            </ScrollViewer>            <!--資料列表結束-->

綁定資料列表:

List<KHModel> lt = new List<KHModel>();                            var khlist = from userdata in xele.Descendants("ROW")                                         select userdata;                            foreach (var khitem in khlist)                            {                                KHModel kh = new KHModel();                                kh.KHBH = khitem.Element("KHBH").Value;                                kh.SSGSBH = khitem.Element("SSGSBH").Value;                                kh.KHMC = khitem.Element("XM").Value;                                kh.GDDH = khitem.Element("GDDH").Value;                                kh.YDDH = khitem.Element("YDDH").Value;                                kh.DZ = khitem.Element("DZ").Value;                                lt.Add(kh);                            }                            listbox1.ItemsSource = lt;                        //實體類        public class KHModel        {            public string KHBH { get; set; }            public string SSGSBH { get; set; }            public string KHMC { get; set; }            public string GDDH { get; set; }            public string YDDH { get; set; }            public string DZ { get; set; }        }

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.