When I try and bind the GridItemsLayout Span property to the ViewModel, it doesn't work.
See sample project (open CollectionViewPage from landing page):
https://github.com/InquisitorJax/Xamarin-Forms-4-Layouts
Is this by design - or a bug?
When I try and bind the GridItemsLayout Span property to the ViewModel, it doesn't work.
See sample project (open CollectionViewPage from landing page):
https://github.com/InquisitorJax/Xamarin-Forms-4-Layouts
Is this by design - or a bug?
Hello, I'm learning to develop both Windows(UWP) and Android app using Xamarin.Forms. When I heard the news that Visual Studio 2019 Preview 2 came to availability, I decided to give it a try.
However, when I tried to create a new Cross-Platform Xamarin.Forms project for both Windows and Android, 'Windows' checkbox was missing on 'select a template' screen, which is currently available on Visual Studio 2017.
Why is that? I know that I can add an Windows project later on after I create an Android-only project, but that process is kinda annoying. Are Microsoft and their Xamarin team going to drop Windows support in the later iteration of Visual Studio and Xamarin? or will they reactivate the option later on?
Hey all, I'm trying to make a Content View where a person can take an item from a ListView, drag it to an image and trigger an event that will delete the item from the ListView. I've been fishing around for NuGet packages that allow you to use a drag and drop functionality but I haven't found much that's usable in Xamarin.Forms. Does anyone know of any package that can be installed to do what I want to do?
Just to clarify, there's two different problems I need to solve: Dragging an item from a list and creating an event that will trigger when a control is dragged to another one. These seem like fairly simple and often used gimmicks in phone applications. I'm not interested in the iOS side of things for now, so something that works fine even if it's just on android would be great. Thank you in advance!
It's began after Xamarin updating
After creating Xamarin forms (Blank Xaml App) project in VS2015 I'm trying to start this project in debug mode with out any changes.
And, in the time of starting compiled app on device I'm getting this error: "element is not of type xamarin.forms.view" (see attachment)
I've tried different devices (emulators and real)
I've tried rebuild all solution and android project itself
I've tried reopen project
I've updated all android SDKs
Nothing is helped, I'm getting the same error every time I start project
Please, help me! I don't know what's the problem
I can't work right now because of this error, I can't start any new project
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
SaveToAlbum = true,
SaveMetaData = true,
Directory = "",
MaxWidthHeight = 1500,
CompressionQuality = 75,
PhotoSize = PhotoSize.Medium,
RotateImage = false,
});
when camera open , it's alway rotated landscape , phone & simulator set Portrait . Have StoreCameraMediaOptions any thing can set this issue ???
AND,
After take photo , can't resize image, i try use BitmapFactory to resize, but not working.
Have any thing can resolve 2 issue above , please tell me.
Thanks So much.
Maybe this doesn't have anything to do with Xamarin, just tesing my understanding of tasks in general I think. I have a task that creates a label among other things and it is in a task so I can keep the activityindicator spinning while it is running. Setting certain properties cause it to fail, for example (PCL) project:
private void Wtf()
{
Task.Run(() =>
{
var oLbl = new Label() { Text = "Order" }; // This works
var oLbl2 = new Label() { FontSize = 10, Text = "Order" }; // This fails
});
}
The error is "The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))" which seems pretty straight forward, but I don't understand how FontSize could be a different thread than the Text property;
Both 'Text' and 'FontSize' are properties of Label. Must be different somehow...?
The Picker has ItemDisplayBinding property to set Itemsource's property name to display by using this "{Binding PropertyA}"
syntax.
But I have UI conditions that relating with changing property name to display dynamically.
I have a property like this.
public string GetPropertyToDisplay
{
If (ID == 1)
{
return "PropertyA";
}else if (ID == 2)
{
return "PropertyB";
}
}
What should I do If I want this property to be binding instead "{Binding PropertyA}"
?
From outside the App - what is the most elegant way to resolve a dependency injection
var service = (IMyService) ((PrismApplicationBase) Application.Current).Container.Resolve(typeof(IMyService));
I am trying to populate a map with locations obtained from an API but it is proving very problematic. When I create a pin from the code behind it shows fine, but it does not show when I use xaml. I would really like to understand what I am doing wrong, thanks! The API successfully stores a longitude and latitude in the ObservableCollection
and I can confirm that through debugging, it is just not represented on the map!
View
<Grid> <maps:Map x:Name="ItemsSource="{Binding Locations}"> <maps:Map.ItemTemplate> <DataTemplate> <maps:Pin Position="{Binding Address="{Binding Name}" Label="{Binding Description}" /> </DataTemplate> </maps:Map.ItemTemplate> </maps:Map> </Grid>
Code-behind
private ITestApiService _testAPIService = new TestApiService(); public MainPage() { InitializeComponent(); BindingContext = new MainPageViewModel(_testAPIService); map.MoveToRegion(MapSpan.FromCenterAndRadius(new Position(51.507351, -0.127758), Distance.FromMiles(100))); } }
ViewModel
class MainPageViewModel { public ObservableCollection<Location> Locations { get; set; } private ITestApiService TestApiService{ get; set; } public MainPageViewModel(ITestApiService testApiService) { TestApiService= testApiService; PopulateEventMapView(); } private async void PopulateEventMapView() { var events = await TestApiService.GetEvents(); Locations = CreateLocation(events); } private ObservableCollection<Location> CreateLocation(List<Event> events) { var locations = new ObservableCollection<Location>(); foreach (var eventItem in events) { locations.Add(new Location(eventItem.Name, eventItem.Description, new Position(eventItem.Venue.Latitude, eventItem.Venue.Longitude))); } return locations; } }
From outside the App - what is the most elegant way to resolve a dependency injection
var service = (IMyService) ((PrismApplicationBase) Application.Current).Container.Resolve(typeof(IMyService));
as Title,if it's possible.
How to set these views Color or FontSize,even design those Layout?
For a registration page , on click of register it calls the rest API to register the user. But after clicking on register if i goes to background and comes to foreground it throws web exception that operation can not be completed and software caused connection abort. Any suggestions how to handle this scenario. It occurs only in iOS. Android works fine. I have enabled background modes also, and provided the interval also for background fetch but it stills throws error. TIA. @JamesMontemagno @JohnMiller @RHudson @jezh @JoeManke
how to create badge in tabbedpage ?
I can't seem to find a Visual Studio setting to enable "Set Next Statement" debugging feature.
I've read old posts suggesting it's not supported, is that correct?
I would like to know if it is possible to change the color of the "barBackgroundColor" of the "navigationPage", what happens is that I have a page where it has a list of colors and when you choose a color, it sends that color to the page of MasterDetail but nothing happens:,Do I need that it runs in real-time? a task?
MasterDetail.xaml
<MasterDetailPage.Master>
<local:MenuPage x:Name="ContePageMenu"/>
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage x:Name="Navigator" BarBackgroundColor="{DynamicResource ColorAzul}" BarTextColor="{DynamicResource ColorBlanco}">
<x:Arguments>
<local:ListaPedidosPage/>
</x:Arguments>
</NavigationPage>
</MasterDetailPage.Detail>
I have a page where I need to display toolbar items only when a button on the screen has been tapped. So far I have the following methods:-
private async Task ClearToolBarItems()
{
var page = Application.Current?.MainPage as Page;
Device.BeginInvokeOnMainThread(() =>
{
if (page != null)
{
page.ToolbarItems.Clear();
}
});
}
private async Task AddToolBarItems()
{
await ClearToolBarItems();
if (JobDetails.Status == JobStatus.InProgress || JobDetails.Status == JobStatus.Accepted)
{
var master = Application.Current?.MainPage as MasterDetailPage;
if (master == null) return;
var page = master.Detail;
var plan = new ToolbarItem("Plan", "", async () => await NavigateToPlan(JobDetails.Id),
ToolbarItemOrder.Secondary);
var schedule = new ToolbarItem("Schedule", "", async () => await NavigateToSchedule(JobDetails.Id),
ToolbarItemOrder.Secondary);
var elevation = new ToolbarItem("Elevation", "", async () => await NavigateToElevation(JobDetails.Id),
ToolbarItemOrder.Secondary);
var email = new ToolbarItem("Send to Email", "", async () => await SendEmailToDefaultAddress(),
ToolbarItemOrder.Secondary);
var abort = new ToolbarItem("Abort Job", "", async () => await AbortJobAsync(JobDetails.Id),
ToolbarItemOrder.Secondary);
await Task.Run(() =>
{
Device.BeginInvokeOnMainThread(() =>
{
page.ToolbarItems.Add(plan);
page.ToolbarItems.Add(schedule);
page.ToolbarItems.Add(elevation);
page.ToolbarItems.Add(email);
if (JobDetails.Status == JobStatus.InProgress)
{
page.ToolbarItems.Add(abort);
}
});
});
}
}
The method of the button tap just calls await AddToolBarItems();
This is working great on Android, but for some reason on iOS the toolbar items do not appear. Am I missing something specific to iOS?
NB I'm following the MVVM pattern, Xamarin Forms 3.5 and .NET Standard shared code.
Hello!
I'm creating a small 2048 clone to practise Xamarin.Forms with MVVM, and I've got a trouble with binding a Row and Column of each square to Grid.
Currently I'm using this ItemsControl:
https /github.com/andreinitescu/XFItemsControl to achieve that.
It works, but it's not reactive at all, so I have to manually clear and fill ItemSource everytime I add or delete an item.
I know it's not the best solution, and it's not performant, my app is lagging everytime I do this.
Can You please suggest me a better option for that ? Maybe Xamarin.Forms already has something that will be useful here?
I will be very grateful for Your help.
<c:BasePage.Content>
<Grid.RowDefinitions>
</Grid.RowDefinitions>
<ScrollView>
<StackLayout>
<ListView HorizontalOptions="FillAndExpand" SelectionMode="None" HasUnevenRows="True" SeparatorVisibility="None" BackgroundColor="Transparent" ItemsSource="{Binding Data}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid >
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ScrollView>
</Grid>
</c:BasePage.Content>
//I know the code can be more elegant - just for explanation purposes
//Showmenu() fires for as many Labels as I put in the stack (Android and iOS). It is a shared project. Forms 3.6.0.293080
for (int ii = 0; ii < someCount; ii++)
{
aSL = new StackLayout();
aSL.Children.Add(new Label { Text="One"});
aSL.Children.Add(new Label { Text="Two"});
aSL.Children.Add(new Label { Text="Three"});
aSL.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(() => { showMenu(); }) });
ViewCell vc = new ViewCell { View = aSL};
aSection.Add(vc);
}
//aSection is a section in a TableView
Hi all,
I can easily read the Characteristic value from my Xiaomi band 3. The value of current time. I used the LightBlue app to connect to it and can see the Datetime value of this device.
From my app, I can get the value is in "E3 07 04 11 0B 1F 08 03 00 00 1C" format. I actually have no idea how to convert it to the date time string. I also tried to find many articles in google but no luck,
Do you have some solution to read this value, and about the writing value to it would be super best.
Thanks & best regards,