Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Google Places Autocomplete不填充地址_C#_Visual Studio_Xamarin.forms_Google Places Api - Fatal编程技术网

C# Google Places Autocomplete不填充地址

C# Google Places Autocomplete不填充地址,c#,visual-studio,xamarin.forms,google-places-api,C#,Visual Studio,Xamarin.forms,Google Places Api,我有一个活跃的Google Places autocomplete,可以使用Xamarin表单或跨平台。我有一个有效的解决方案,当用户键入地址时自动填充地址。我的问题是,当用户从列表中选择它时,地址不会进入搜索栏。文本…搜索栏只保留键入的文本?选择在搜索栏中填充时如何获取文本 我是Xamarin forms和C#的新手 在ItemSelected方法中,需要设置搜索栏的文本: async void Results_List_ItemSelected(object sender, Selected

我有一个活跃的Google Places autocomplete,可以使用Xamarin表单或跨平台。我有一个有效的解决方案,当用户键入地址时自动填充地址。我的问题是,当用户从列表中选择它时,地址不会进入搜索栏。文本…搜索栏只保留键入的文本?选择在搜索栏中填充时如何获取文本

我是Xamarin forms和C#的新手


在ItemSelected方法中,需要设置搜索栏的文本:

async void Results_List_ItemSelected(object sender, SelectedItemChangedEventArgs e)
    {
        if (e.SelectedItem == null)
            return;

        var prediction = (AutoCompletePrediction)e.SelectedItem;

        search_bar.Text = prediction.Name? // Your property here

        results_list.SelectedItem = null;

        var place = await Places.GetPlace(prediction.Place_ID, GooglePlacesApiKey);

        if (place != null)
            await DisplayAlert(
                place.Name, string.Format("Lat: {0}\nLon: {1}", place.Latitude, place.Longitude), "OK");

    } 

我仍在尝试修复此问题,它只添加街道名称和编号,而不是整个地址

异步无效结果\u列表\u ItemSelected(对象发件人,SelectedItemChangedEventArgs e){if(e.SelectedItem==null)return;var prediction=(自动完成预测)e、 SelectedItem;results_list.SelectedItem=null;var place=wait Places.GetPlace(prediction.place_ID,GooglePlacesApiKey);if(place!=null)wait DisplayAlert(place.Name,string.Format(“Lat:{0}\nLon:{1}”、place lation.Latitude,place.Longitude),“OK”);}我猜这与结果有关?列表中的哪个行正在更改
搜索栏的
文本,在Results_List_ItemSelected中,您应该将搜索栏文本设置为他们选择的内容我对c不熟悉?我怎么添加它?我对c不熟悉?我怎么添加它?我只是用代码来实现。search\u bar.Text=YourProperty您想要显示的AutoCompletePrediction类是什么?Thx您救了我的命它可以工作,但它只添加街道名称和号码,而不添加城市和州
async void Results_List_ItemSelected(object sender, SelectedItemChangedEventArgs e)
    {
        if (e.SelectedItem == null)
            return;

        var prediction = (AutoCompletePrediction)e.SelectedItem;

        search_bar.Text = prediction.Name? // Your property here

        results_list.SelectedItem = null;

        var place = await Places.GetPlace(prediction.Place_ID, GooglePlacesApiKey);

        if (place != null)
            await DisplayAlert(
                place.Name, string.Format("Lat: {0}\nLon: {1}", place.Latitude, place.Longitude), "OK");

    }