Hello friends. How do I refresh all the list views in the project at the same time ?
Refresh all list view
How to prevent pages from navigating Multiple Forms
In Xamarin Forms, I have a list view and on tapping one item in the list view it will be taking us to the next content view. If I am tapping the item in the list view quickly for multiple times we can see the screens are navigated multiple times. How can we avoid it?
Loading an Image from a Resource in xaml
I have a resource called biglogo.png
added via the Resource menu and now it's in the Resources folder of my project.
I want to use it via xaml but neither
nor
seem to work. Is there a straightforward way to make it work?
How can I access Navigation from within a ViewCell?
Let's say that I have a custom ViewCell
for a ListView
, where each cell contains a button. When a user clicks that button I'd like to be able to push a new page onto the navigation stack. The problem is that because I'm not inside the ContentPage
, but in a ViewCell
, I don't have access to the Navigation
property.
The cells themselves are also managed automatically through the ListView
, so as far as I know I don't have a way to pass the parent ContentPage
through the constructor, right?
Is there a way to access the Navigation
features from the ViewCell
? Or do I need to somehow restructure my ListView
to pass the ContentPage
through to each ViewCell
?
Style.Triggers TargetType="Button" Property="IsEnabled"
Hello,
I wanted to give a new try to Triggers to avoid using converters / VisualState / CustomRenderer.
I got a ListView filled with data which contains several buttons. Those buttons have their IsEnabled property binded and they use a style which use a Trigger to change the TextColor / Opacity / BackgroundColor to show to user that a button is either available or not.
It doesn't seems to work as I expect.
Here is the style :
<Style x:Key="ContextualCellButtonStyle" TargetType="Button">
<Style.Triggers>
<Trigger TargetType="Button" Property="IsEnabled" Value="False">
<Setter Property="Text" Value="IsEnabled=False" />
<Setter Property="TextColor" Value="Green" />
<Setter Property="BackgroundColor" Value="Red" />
</Trigger>
<Trigger TargetType="Button" Property="IsEnabled" Value="True">
<Setter Property="Text" Value="IsEnabled=True" />
<Setter Property="TextColor" Value="Red" />
<Setter Property="BackgroundColor" Value="Green" />
</Trigger>
</Style.Triggers>
</Style>
(The values used are not the final one, it's just to debug)
As you can see, when a button is enabled, the text should be IsEnabled=True with a green background and red foreground.
If the button is not enabled, the text should be IsEnabled=False with a red background and green foreground.
In my design time model, I've set the first item to enabled and the second one to disabled :
And in my XAML, I have this :
Here is the result I got :
You can see that when the IsEnabled=False, it uses the trigger IsEnabled=True and when the IsEnabled is set to true, I don't have the style I want too.
I guess the Triggers work when the IsEnabled property changes at runtime but I'm not sure. If it is the case, what do you recommend ? A custom control ? A custom renderer ?
I would like to avoid VisualState because I'd like to use MVVM without code behind for this stuff.
I have already written some custom renderer like this but I thought Trigger would be better in this case so I won't have to create a custom control and a custom renderer :
Any help or suggestion is welcomed.
Thanks for reading so far !
Binding to an element of an array (or List)
After much googling, I haven't found an answer to this.
I have an array of colors. I want to bind a Button's BorderColor to a specific element within an array.
What is the syntax to achieve this?
Xaml:
BorderColor="{Binding ButtonColors[11], Converter={Services:ByteToBorderColourConverter}}"
ViewModel:
private List<byte> buttoncolors;
public List<Byte> ButtonColors
{
get => buttoncolors;
set
{
buttoncolors = value;
OnPropertyChanged();
}
}
...
ButtonColors[11] = (Byte)Data[3];
I've also tried implementing this with List, but it also doesn't work.
I think the xaml binding syntax is incorrect maybe?
An image is not centered correctly
Dear experts,
In my application I need to center an image vertically and horizontally within a ListView header.
<ListView x:Name="MenuItemsListView"
SeparatorVisibility="None"
HasUnevenRows="true"
ItemsSource="{Binding MenuItems}">
<ListView.Header>
<StackLayout BackgroundColor="Black" HeightRequest="100">
<Image HeightRequest="80" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Source="Assets\logo.png" />
</StackLayout>
</ListView.Header>
<ListView.ItemTemplate>
I don't understand why the black space under the image is higher than the black space above the image. I tried a Grid instead of the StackLayout with row heights 10, Auto, 10 with the same result. How can I fix that?
Thanks,
Dmitriy
UpdateSourceTrigger
I would like to know if in Xamarin.Forms it is also possible to modify two-way binding with the “UpdateSourceTrigger”option like in WPF, where it is possible to specify a bound attribute for example like this:
Text="{Binding StringData, Mode=TwoWay, UpdateSourceTrigger=Explicit}"
I just found this unanswered question:
Does anyone know whether and how this is implemented in Xamarin.Forms?
Xamarin form :How to search in listview
I have listview in which data coming from web api, i want to search in listview with character wise, the problem i am facing when is start searching its working fine but its getting very very slow need some solution to fix it. Here is my code
private async void Entry_TextChanged(object sender, TextChangedEventArgs e)
{
var httpClient = new HttpClient();
var json = await httpClient.GetStringAsync(" http://172.16.4.212:51583/api/GetItems");
var admtPatients = JsonConvert.DeserializeObject<List<tblItem>>(json);
ObservableCollection<tblItem> trends = new ObservableCollection<tblItem>(admtPatients);
if (string.IsNullOrEmpty(medicine.Text))
{
MyListView.ItemsSource = trends;
}
else
{
MyListView.ItemsSource = trends. Where(x => x.strItemName.ToLowerInvariant().Contains(e.NewTextValue.ToLowerInvariant()) || x.strItemName.ToUpperInvariant().Contains(e.NewTextValue.ToUpperInvariant()));
}
//await ((MainViewModel)this.BindingContext).LoadCountNotificationAsync();
}
Hide a specific child page of a CarouselPage
Hi Guys,
I need a way to hide a specific carousel page. I do not want to remove the page as a whole because then I would lose all the changes made on that particular page which I want to maintain like Field changes, Scroll position, control states and so on. Possible? I dont mind using TabbedPage is this feature is only possible on that.
Thanks.
How to Use PullToRefreshLayout control in StackLayout in Xamarin.Forms ?
Anyone Please Share the code
Bad location Google Maps Xamarin Forms (Middle of the ocean)
I'm using Xamarin.forms.Maps and ExtendedMap, I did make a custom control, here I can get the location when the user tap on map but by default the map position is in the middle of the occean, something like this 0.0756931, 0.0786793. I was seaching and trying for a while but I did not find the solution.
I did see that the map is loading the region.LatitudeDegrees and region.LongitudeDegrees but I really don't why is this happen,
Xamarin.Forms 3.0.0.482510
Xamarin.Forms.Maps 3.0.0.482510
Xamarin.Plugin.ExternalMaps 4.0.1
MapGoogleView.xaml
<local:ExtendedMap
WidthRequest="320" HeightRequest="200"
x:Name="MyMap" Tap="OnTap"
IsShowingUser="true"
MapType="Street"/>
MapGoogleView.xaml.cs
public MapGoogleView(double lat, double lon)
{
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
var map = new ExtendedMap(
MapSpan.FromCenterAndRadius(
new Position(lat, lon), Distance.FromMiles(0.3)))
{
IsShowingUser = true,
HeightRequest = 100,
WidthRequest = 900,
VerticalOptions = LayoutOptions.FillAndExpand,
MapType = MapType.Street
};
var stack = new StackLayout { Spacing = 0 };
stack.Children.Add(map);
Content = stack;
var position = new Position(lat, lon); // Latitude, Longitude
var pin = new Pin
{
Type = PinType.Generic,
Position = position,
Label = "Ubicación",
Address = "Latitud: " + lat.ToString() + ", Longitud: " + lon.ToString(),
};
MyMap.Pins.Add(pin);
map.MoveToRegion(
MapSpan.FromCenterAndRadius(
new Position(lat, lon), Distance.FromMiles(1)));
}
ExtendedMap.cs
public class ExtendedMap : Map
{
public event EventHandler<TapEventArgs> Tap;
public ExtendedMap()
{
}
public ExtendedMap(MapSpan region) : base(region)
{
}
public void OnTap(Position coordinate)
{
OnTap(new TapEventArgs { Position = coordinate });
}
public async void OnTap(Position coordinate)
{
try
{
OnTap(new TapEventArgs { Position = coordinate });
}
catch (Exception error)
{
await Application.Current.MainPage.DisplayAlert(
"Error",
error.Message,
"Aceptar");
return;
}
}
protected virtual void OnTap(TapEventArgs e)
{
var handler = Tap;
if (handler != null) handler(this, e);
}
}
public class TapEventArgs : EventArgs
{
public Position Position { get; set; }
}
}
Droid
ExtendedMapRenderer.cs
public class ExtendedMapRenderer : MapRenderer, IOnMapReadyCallback
{
private GoogleMap _map;
public void OnMapReady(GoogleMap googleMap)
{
_map = googleMap;
if (_map != null)
//_map.GestureRecognizer.Add(new);
_map.MapClick += googleMap_MapClick;
}
public ExtendedMapRenderer()
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Map> e) //cambiar a xamarin.forms.view
{
if (_map != null)
_map.MapClick -= googleMap_MapClick;
base.OnElementChanged(e);
if (Control != null)
((MapView)Control).GetMapAsync(this);
}
private void googleMap_MapClick(object sender, GoogleMap.MapClickEventArgs e)
{
((ExtendedMap)Element).OnTap(new Position(e.Point.Latitude, e.Point.Longitude));
}
}
I need the map can be centered on my position, I am get the position using Xam.Plugin.Geolocator
Thanks in advance.
Listview Issue
Hello i am now having a problem with my listview
this is what were trying to achieve
but i get stuck because i have no idea how i can like cut viewcells and place them next to eachother.
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<StackLayout HorizontalOptions=" VerticalOptions=" HeightRequest=" WidthRequest="100">
<Image Source="{Binding ImageNaam}"
Aspect="AspectFit"/>
</StackLayout>
<Label Text="{Binding GerechtNaam}"
TextColor="Black"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Start"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Picker popup is shown twice when calling focus()
Hello
I've an issue when a Picker (in my example an ExtendedPicker, but it also happens with a normal Picker). In some cases (see below), when calling Picker's focus() method, the popup opens twice in Android simulator (not sure about iOS/real device).
In my case I've got a ListView with a Picker on each item. They work as long as I don't delete an item. After I deleted an item, on some still existing items when opening Picker, it's opened twice.
To reproduce the problem, you can load the project from here: https://github.com/skurth/App1
1) Start app
2) Delete group "Tübach City" by pressing "Delete" button next to it.
3) Press on one of the three "Kopf" buttons from group "PSW Tübach" (not from group "1. FC Schwangere Bergente", there still one popup opens correctly). They open a picker.
4) Press OK on the opened Picker.
5) Another picker popup is shown. Why?
Is there something I do wrong or is it a bug?
Relevant code is in file "ItemCell.cs", starting from line 39.
(The reason why I set picker IsVisble=false and using a button instead of the standard picker label is because I need to customize font etc., and this way it's easier than writing a custom renderer for Picker.)
IOS Submission Rejected Cause of CallKit and CallKit Blocker
Hey everyone,
I have a problem about CallKit and CallKit Blocker. When i submit Xamarin.Forms app to IOS they said :
Guideline 2.3 - Performance - Accurate Metadata
We were unable to locate some of the features described in your metadata.
Specifically, we were unable to locate CallKit and CallKit Blocker features and functionality in the app. /both flags were present in MG during review.
Im not using callkit in my application and Linker Behavior is Link Framework SDKs Only.
Thank you
Samsung keyboard covers entry cells in xamarin forms; Other android and iOS seem to work w/o issue
I have a form with a table view to display info to the user as well as let them edit it.
<StackLayout>
<Frame>
<TableView>
<TableRoot>
<TableSection>
<EntryCell/>
</TableSection>
<TableSection>
<ViewCell>
<StackLayout >
<Label />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Editor Text="{Binding Service.ExtProblem, Mode=TwoWay}"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
AutoSize="TextChanges"
InputTransparent="{Binding ProblemLocked}"/>
</Grid>
</StackLayout>
<EntryCell Keyboard="Numeric"
x:Name="AmtToCollectEntry"
Label="Amt To Collect"
Placeholder="$0.00"
Text="{Binding Service.AmtToCollect, Mode=TwoWay, Converter={StaticResource CurrencyConverter}}"
LabelColor="{DynamicResource headerFooterIconColor}"/>
</TableSection>
</TableRoot>
</TableView>
</Frame>
</StackLayout>
This is the basic format of the form, with a few more of the ViewCells
containing Editors
. For whatever reason when some of my testers with Samsung devices try to use the form, the keyboard covers the entry fields so the user can't see what they are typing. Additionally, when first selecting the numeric EntryCell
, it seems to get deselected and none of the input gets recorded. Some playing around on the form and coming back seems to let you select it correctly the second time.
What's weird is I can't repeat this with another android device (Google pixel and some no-name android tablet) or iOS. Anything I was able to research on it seemed to only come up with iOS keyboard issues and a few years old. Please help.
how to bind selected date to viewmodel in xamarin forms using date picker
I am trying to bind the selected date from DatePicker to ViewModel.
I have tried like this:
<DatePicker Date="{Binding Path=MyList.DOB}">
</DatePicker>
can you please anyone suggest me how to bind the date from the datapicker in xamarin forms using XAML
How to design tabbed page inside tabbed and list view?
Advance thanks.
Anandhamurugan.
Underlying connection closed error when running UI Tests
SetUp : System.Net.Http.HttpRequestException : An error occurred while sending the request.
----> System.Net.WebException : The underlying connection was closed: The connection was closed unexpectedly.
at Xamarin.UITest.Shared.Http.HttpClient.SendData(String endpoint, String method, HttpContent content, ExceptionPolicy exceptionPolicy, Nullable1 timeOut) at Xamarin.UITest.Shared.Http.HttpClient.Post(String endpoint, String arguments, ExceptionPolicy exceptionPolicy, Nullable
1 timeOut)
at Xamarin.UITest.Shared.Android.HttpApplicationStarter.Execute(String intentJson)
at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.LaunchApp(String appPackageName, ApkFile testServerApkFile, Int32 testServerPort)
at Xamarin.UITest.Android.AndroidApp..ctor(IAndroidAppConfiguration appConfiguration, IExecutor executor)
at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
at Elog.UITest.Regression59.BeforeEachTest()
--WebException
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
ENV:
Xamarin 4.11.0.776 (d15-8@1ae9b59d7)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 4.15.9 (d000f568b)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 1.1.116 (9619170)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 9.0.0.19 (HEAD/a8a3b0ec7)
Xamarin.Android Reference Assemblies and MSBuild support.
Xamarin.iOS and Xamarin.Mac SDK 12.0.0.15 (84552a4)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Andriod SDK 8.1 Oreo, Platform 27
Visual Studio 15.8.4
ListView Grouping ShortName Appearance
Is there anyway to update how the GroupShortName appears on screen? I am getting reports from users saying that they are too small and hard to click on. We only have 3 groups in our ListView so if we could increase the size or spacing for the short names I believe we could improve user experience.
Does anyone know if it's possible to update that appearance?