我的HyperlinkBut​​ton有什么问题?

时间:2015-04-26 23:38:40

标签: c# xaml silverlight windows-phone-7 hyperlink

我通过更改我的HyperlinkBut​​ton样式使我的列表变得更好,然后我的应用程序停止工作..调试器对我没有任何显示。

我的xaml代码:

<ListBox Name="Listing" ItemsSource="{Binding Coletores,Mode=TwoWay}" HorizontalAlignment="Stretch">
                    <ListBox.ItemTemplate>
                        <DataTemplate>

                            <StackPanel VerticalAlignment="Stretch">
                                <HyperlinkButton NavigateUri="/OcorrenciasPage.xaml" Name="hlbColetor" Click="hlbColetor_Click">
                                    <HyperlinkButton.Content>
                                        <StackPanel>
                                            <TextBlock Text="{Binding Nome}" FontSize="42"/>
                                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                                <TextBlock FontSize="24" FontWeight="Light">
                                                    <Run Text="x:"/>
                                                    <Run Text="{Binding Latitude}"/>
                                                </TextBlock>
                                                <TextBlock FontSize="24" FontWeight="Light" Margin="20,0,0,0">
                                                    <Run Text="y:"/>
                                                    <Run Text="{Binding Longitude}"/>
                                                </TextBlock>
                                            </StackPanel>
                                        </StackPanel>
                                    </HyperlinkButton.Content>
                                </HyperlinkButton>
                                <Line Width="*" Stroke="Gray" StrokeThickness="4"/> 
                            </StackPanel>

                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

背后的代码:

public ColetoresPage()
        {
            InitializeComponent();

            db = new AppDataContext();

            DataContext = this;      
        }

        private ObservableCollection<Coletor> _coletor;
        public ObservableCollection<Coletor> Coletores
        {
            get { return _coletor; }
            set
            {
                _coletor = value;
                OnPropertyChanged("Coletores");
            }
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Coletores = new ObservableCollection<Coletor>(PessoaAux.coletores);
        }

        private void hlbColetor_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;
            if (btn != null)
            {
                Coletor coletor = btn.DataContext as Coletor;
                ColetorAux.id = coletor.Id;
                ColetorAux.nome = coletor.Nome;
                ColetorAux.longitude = coletor.Longitude;
                ColetorAux.latitude = coletor.Latitude;
                ColetorAux.pessoa = coletor.Pessoa;
            }
        }

我不知道出了什么问题,我的代码在进行一些编辑之前运行正常,但我不知道我做了什么编辑就是在窃听我的代码

0 个答案:

没有答案