Hello folks! Hope you are doing great!
Im trying to center my app logo using TitleView but it's impossible to achieve that when I have the arrow icon in the nav bar.
Some code:
Anyone know how to solve this?
Hello folks! Hope you are doing great!
Im trying to center my app logo using TitleView but it's impossible to achieve that when I have the arrow icon in the nav bar.
Some code:
Anyone know how to solve this?
Hi everyone, first question ever.
I am very new on Xamarin, making my first project, so I would very much appreciate detailed answers.
My app consists basically on a book. I am using CarouselPage, in which every chapter of the book is one of the carousel pages.
My question is how do I make sure that every time someone runs the app, it "saves the progress" and opens where you left it last time.
Thanks everyone!
I'm trying to use WebView.EvaluateJavaScriptAsync.
I'm just using this page to test with
If you try it in Chrome and in the debug console typemyFunction(123, 456)
It says "56088".
But in Xamarin.Forms if I do:
string result = await webView.EvaluateJavaScriptAsync($"myFunction(123, 456)");
result is always null
I can do other things, and they work fine:
string result2 = await webView.EvaluateJavaScriptAsync("27 + 92");
string result3 = await webView.EvaluateJavaScriptAsync("alert('hey')");
string documentBodyInnerHTML = await webView.EvaluateJavaScriptAsync("document.body.innerHTML");
Anyone know how to get this working?
Hi all,
I have been working to develop my first Xamarim forms apps for 2 months straight now. So far I have been able to find answers by researching on this forum except for this one.
I used Microsoft.EntityFrameWorkCore.Sqlite to manage an internal database on the device. When I add entities (records) to an instance of my context, or when I call EnsureCreate, no problem if I am running without linking anything (i.e. linker set to none). However when I set linker to link SDK assemblies only, I cannot execute any action on the database be that adding an entity or even calling EnsureCreate. Error message System.ArgumentNullException: 'Value cannot be null.
Parameter name: key'
I really need to publish this app, so I submitted it without any linking. Google Playstore accepted it despite the larger size, but Apple app store rejected it saying that assembly is too large.
I hope someone can help me get back on track.
I've just started working with Xamarin Forms and I'm trying to wrap my head around a couple of things that are (not) happening relating to a bound ListView, hopefully someone can shed some light on this for me.
private Item _SelectedItem; public Item SelectedItem; { get => _SelectedItem; set { _SelectedItem; = value; NotifyPropertyChanged("SelectedItem"); } } public ObservableCollection<Item> ItemsList { get; set; } public ICommand RemoveItemCommand { get; private set; } public MyViewModel() { RemoveItemCommand = new Command(RemoveItem, CanRemoveItem); } private void RemoveItem() { ItemsList.Remove(SelectedItem); } private bool CanRemoveItem() { return SelectedItem != null; //return true; }
And the Xaml:
When a row is selected there is no visual indication that it has been selected (ie. row is not highlighted)
When a row is selected, the SelectedItem property in my ViewModel contains the selected correct object, but the
CanRemoveItem property of the command is never set to true so the button is always disabled. However, RemoveItem method and button work when CanRemoveItem is manually set to true.
Is this expected behaviour or am I missing the mark somewhere?
I am getting a designtime error when referencing a property in an object in the list of objects in the hardcoded x:Array list:
"The attachable property "id" was not found in type "child""
Here is my code:
<CollectionView x:Name="lst" SelectionMode="Single" SelectionChanged="lst_SelectionChanged" SelectedItem=""> <d:CollectionView.ItemsSource> <x:Array Type="{x:Type models:Line}"> <models:Line Col.Id="1"/> <models:Line Col.Id="2"/> <models:Line Col.Id="3"/> </x:Array> </d:CollectionView.ItemsSource>
The squiggly line is under Column.Id, it seems to not accept a property in a object
The type is of object Line, that has an object of class Column, they are declared as the folllowing
public class Line
{
public Column Col { get; set; }
}
public class Column
{
public string Id { get; set; }
}
The models reference is just
xmlns:models="clr-namespace:MyApp;assembly=MyApp"
Any way to use complex binding like Col.Id at all?
Hi. I am trying to play a video in my application.
I placed my video "Dice65.mpg" in Android /Resources/raw directory.
My Xaml looks like this: (used brackets because the forum code kept hiding stacklayout and media element.
<ContentPage.Content>
[StackLayout]
[MediaElement x:Name="VideoPlayer" ShowsPlaybackControls="False" /]
[/StackLayout]
</ContentPage.Content>
My Xaml.cs looks like this:
public DiceRoll()
{
InitializeComponent();
VideoPlayer.Source = "ms-appx:///Dice65.mp4";
}
I get this error:
System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'
The documentation didn't seem to imply that anything else was needed. Am I missing something?
Thank you.
Hi,
I'm trying out the MediaManager plugin and get it to start with no problem with just this:
CrossMediaManager.Current.Play("https://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4", MediaFileType.Video);
My only problem is that I don't get any controlls, I just wan't to have the native ones but they don't show up. Do I have to call for them in some way?
Best regards
/magnus
Hi Everyone! I am really trying to love Xamarin, but I'm running into some await / async / Page Load issues.
If anyone has any suggestions as to what I am doing wrong, feedback would be greatly appreciated!
The user starts my game in PlayersHandPage() and from there selects cards and clicks Play which, in turn,
calls public static async Task PlayCards() in App.Xaml.cs (below). I've tried all sorts of variations as to
what gets an async and what does not. I'm certain I'm doing something wrong! :X
In it's current state, what is happening is that while loop in "public static async Task PlayCards()"
runs forever and, on the screen, the PlayerHandPage() freezes. I can see the StateGridPage() call execute
in App.SetMainPage(new StateGridPage()); but the page never loads (on the screen) and the while loop
immediately continues looping.
Thank you again for any help! I am baffled.
//Code in App.Xaml.CS public static async Task SetMainPage(Page newPage) { Task.Run(async () => { //await Task.Delay(500); // was 300 Device.BeginInvokeOnMainThread(() => { App.Current.MainPage = newPage; }); }); } // This method gets called from the PlayersHandPage(). There is a play button that gets // pressed. My intention is for the user, then, to be done with the PlayersHandPage, // processing will then take place in App.Xaml.cs which will decide, via GameFunctions.PlayCard // whether the StateGridPage (state chooser) needs to be called or whether the PlayersHandPage() // should be reloaded. public static async Task PlayCards() { while (CurrentGame.CurrentSelectedCards.Count > 0) { await GameFunctions.PlayCard(App.CurrentGame.CurrentSelectedCards.FirstOrDefault()); } SetMainPage(new PlayersHandPage()); } //Code in GameFunctions public static async Task PlayCard(KeyValuePair<Int32, Models.Card> myCard) { // Play Card was designed to work like a state engine. Basically, my // intention is to call it over and over until all cards are finished being // processed. In the case of the DEA Agent, a state needs to be chosen // so I am trying to send the user to the StateGridPage which sets // App.CurrentGame.SelectedState. Then, when the method is called again // it should assign the value it retrieved by calling the StateGridPage, // discard the card, and reload the PlayersHandPage which kicked off the // whole process when the user selected a card and clicked the play button // which in turn called PlayCards() in App.xaml.cs. // switch (myCard.Value.CardType) { case (Models.Card.CardTypes.DEAAgent): // First check to see if there are any places for a DEA Agent Dictionary<string, Models.USState> PossibleStates = App.CurrentGame.States.Where(x => !x.Value.HasDEA).ToDictionary(x => x.Key, x => x.Value); if (App.CurrentGame.CardAction.SelectedState.Length == 0) // Nothing has been done yet { App.CurrentGame.CardAction.Clear(myCard.Key, Models.CardSteps.PlayerActions.PlaceDEAAgent); App.CurrentGame.CardAction.Message = "Where do you want to place the DEA Agent?"; // Navigate to State Grid App.SetMainPage(new StateGridPage()); // Here I am calling the StateGridPage so the user can pick a state for the card } else // A card has already been selected { // Mark to Remove from player's hand alRemove.Add(myCard.Key); // Since the card is no longer in the players hand, there would be no more selected cards // however, I am currently not getting this far because the StateGridPage() is not appearing // to let me choose a state // Add to discard pile App.CurrentGame.DiscardPile.Add(myCard.Key, myCard.Value); // Make sure nothing else has the DEA card foreach (String strStateName in App.CurrentGame.States.Keys) App.CurrentGame.States[strStateName].HasDEA = false; // Move the DEA card to this state App.CurrentGame.States[App.CurrentGame.CardAction.SelectedState].HasDEA = true; // Clear the card action because we are done App.CurrentGame.CardAction.Clear(); } break;
I have a simple Xamarin Form app with a .net standard project and Android Project. I am facing a problem since day of development is that , I am unable to pull Toast and Activity Indicator on form. I dont know why. I tried almost all major plugins as well.
Here's my login code where I want to see a toast. I have used UserDialogs, Forms.Plugin etc and now using Plugin.Toast.
protected void BtnLogin_Clicked(object sender, EventArgs e) { try { CrossToastPopUp.Current.ShowToastMessage("Message"); // Plugin.Toast package var userName = TxtUserName.Text.Trim(); var password = TxtPassword.Text.Trim(); userController.DoLogin(userName, password); } catch (NullReferenceException) { DisplayAlert("Mobile # and Password, both are required.", "JCAA", "OK"); } catch (Exception ex) { DisplayAlert(ex.Message, "JCAA", "OK"); Crashes.TrackError(ex); } }
The shell can be used for one thing only with almost no customization whatsoever. I fail to see the point in putting so much time and effort into a glorified uneditable template that forces a specific design on the app. I don’t think any real world app could use the shell. Considering the thousands of open bugs, and how a ton of basic functionality is missing, is the shell something that will keep on taking whatever scarce development resources the team has or will it be put to pasture at some point so resources can be spent wiser?
Thanks.
xmlns:video="clr-namespace:proj.Controls.Video"
private void Rotate_Clicked(object sender, EventArgs e)
{
if (videoPlayer.sRotate == false)
{
videoPlayer.sRotate = true;
}
else
{
videoPlayer.sRotate = false;
}
}
The videoPlayer.sRotate is Enable in Android and IOSis not work.Is something other need for IOS or Any Other way for rotate the videoplayer
Hello
Have a Xamarin Forms app on iOS.
When testing on physical device (iPhone), when the app is switched to background and then to foreground, it restarts.
Expected behaviour is to resume from where it left off.
Works fine on simulator.
Pl advise asap.
Thanks
Hello guys i am trying to integrate push notification into my app using this API
https://docs.pushwoosh.com/platform-docs/api-reference/device-api
I want to ask how and where can i find the Device Token in Xamarin forms
i use the plugin to get the DEVICE info
https://github.com/jamesmontemagno/DeviceInfoPlugin
but sode not have Device Token
I am trying to set a binding in C#. It's initialised once properly and then I get a warning that the control is looking into a different ViewModel for the property and does not update.
Is my view somehow overwriting the binding context of the control that I set in C#, if so how can I tell it to keep i'ts binding?
It does not seem to happen for controls that are binded in xaml
I am planning to develop a TV application which should run on Amazon Fire TV
, ChromeCast
, Roku
and Apple TV
. For this, I have created a Xamarin Forms project with Android and IOS projects. Is that type project support all the above-mentioned devices?
I have created 2 Android TV Emulators with different Resolution (Screenshot added below). When I run the newly created XF project on the TV emulator, nothing is showing on the emulator. Only a black screen is visible on the UI. For running a project into a TV emulator should I add anything else?
Emulator List:
Emulator When running the Project:
For IOS there are no TV Simulators available on my VS, only iPhone and iPad simulators are available on it. So How can I create a TV Simulator on VS for Mac?
Simulator List:
xaml:
<ContentPage.Resources>
</ContentPage.Resources>
<ContentPage.Content>
xaml.cs:
namespace EZQueue.Views.BookAppointment
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class TimeSlotList : ContentPage
{
VMTimeSlotList VMModel;
public ServiceSlot serviceSlot { get; set; }
public WorkTemplate workTemplate { get; set; }
public ApointingPerson apointingPerson { get; set; }
DayList dayList { get; set; }
public TimeSlotList(ServiceSlot InputServiceSlot,ApointingPerson InputapointingPerson) { InitializeComponent(); apointingPerson = InputapointingPerson; ApointingPersonName.Text = apointingPerson.Name; ApointingPersonTag.Text = InputServiceSlot.TagList; serviceSlot = InputServiceSlot; VMModel = new VMTimeSlotList(serviceSlot); BindingContext = VMModel; GetTimeSlotList(); GetWorkTemplateList(); GetCancelServiceList(); } async void GetTimeSlotList() { await VMModel.RefreshListAsync(); } async void GetWorkTemplateList() { await VMModel.RefreshWorkTemplateAsync(); } async void GetCancelServiceList() { await VMModel.RefreshGetCancelServiceAsync(); } async void GetSlotListData() { await VMModel.RefreshGetSlotListDataAsync(); SlotListView.ItemsSource = VMModel.SlotListDataGroup; SlotContentView.IsVisible = true; } private void DayButton_Clicked(object sender, EventArgs e) { SlotContentView.IsVisible = false; SlotNOView.IsVisible = false; Button btn = (Button)sender; dayList=(DayList)btn.BindingContext; VMTimeSlotList.SelectedDate = DateTime.Parse(dayList.date); SelectedDayHead.Text = dayList.dayString + ", " + dayList.date; checkSoltAvailableORNot(); } public void checkSoltAvailableORNot() { switch (dayList.dayString) { case "Monday": if (VMModel.workTemplate.Monday == true) { GetSlotListData(); } else { slotNOAvailable(); } break; case "Tuesday": if (VMModel.workTemplate.Tuesday == true) { GetSlotListData(); } else { slotNOAvailable(); } break; case "Wednesday": if (VMModel.workTemplate.Wednesday == true) { GetSlotListData(); } else { slotNOAvailable(); } break; case "Thursday": if (VMModel.workTemplate.Thursday == true) { GetSlotListData(); } else { slotNOAvailable(); } break; case "Friday": if (VMModel.workTemplate.Friday == true) { GetSlotListData(); } else { slotNOAvailable(); } break; case "Saturday": if (VMModel.workTemplate.Saturday == true) { GetSlotListData(); } else { slotNOAvailable(); } break; case "Sunday": if (VMModel.workTemplate.Sunday == true) { GetSlotListData(); } else { slotNOAvailable(); } break; } } public void slotNOAvailable() { SlotNOAvailable.Text = "Slot NOT Available...!!"; SlotNOView.IsVisible = true; } private void SelectedSlot_Clicked(object sender, EventArgs e) { Button btn = (Button)sender; SlotListData SelectedTime = (SlotListData)btn.BindingContext; Navigation.PushAsync(new CustomerDetail(SelectedTime,VMModel.workTemplate,apointingPerson,dayList) { Title = "Patient Details" }); } }
}
vMmodel:
namespace EZQueue.ViewModels
{
public class CancelStartEnd
{
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
}
public class VMTimeSlotList : INotifyPropertyChanged { public ObservableCollection<DayList> dayListAll { get; set; } = new ObservableCollection<DayList>(); public ObservableCollection<DayList> dayList { get; set; } = new ObservableCollection<DayList>(); public ObservableCollection<CancelService> cancelServiceAll { get; set; } = new ObservableCollection<CancelService>(); public ObservableCollection<CancelService> cancelService { get; set; } = new ObservableCollection<CancelService>(); public CancelStartEnd cancelStartEnd { get; set; } = new CancelStartEnd(); public WorkTemplate workTemplateAll { get; set; } = new WorkTemplate(); public WorkTemplate workTemplate { get; set; } = new WorkTemplate(); public List<SlotListData> SlotListDataGroupAll { get; set; } = new List<SlotListData>(); public List<SlotListData> SlotListDataGroup { get; set; } = new List<SlotListData>(); DateTime TodayDate = DateTime.Today.AddDays(0); public ObservableCollection<Appointment> appointment { get; set; } = new ObservableCollection<Appointment>(); public int serviceSlotID { get; set; } public static DateTime SelectedDate { get; set; } public List<string> BookedAppointmentTime { get; set; } = new List<string>(); public VMTimeSlotList(ServiceSlot InputServiceSlot) { serviceSlotID = InputServiceSlot.ServiceSlotID; } private void UpdatelistDayList() { dayList.Clear(); foreach (var item in dayListAll) { dayList.Add(item); } UpdateUserPromt(); } public async Task RefreshListAsync() { IsRefreshing = true; try { dayListAll = await WebManager.GetDayListAsync(TodayDate, serviceSlotID); UpdatelistDayList(); } catch { } IsRefreshing = false; } private void UpdateWorkTemplate() { workTemplate = workTemplateAll; UpdateUserPromt(); } private void UpdateSlotListData() { SlotListDataGroup.Clear(); foreach (var item in SlotListDataGroupAll) { SlotListDataGroup.Add(item); } UpdateUserPromt(); } public async Task RefreshWorkTemplateAsync() { IsRefreshing = true; try { workTemplateAll = await WebManager.GetWorkTemplateAsync(serviceSlotID); UpdateWorkTemplate(); } catch {} IsRefreshing = false; } public async Task RefreshGetSlotListDataAsync() { IsRefreshing = true; try { await getCancelServiceAsync(); await getappointmentAsync(); SlotListDataGroupAll.Clear(); DateTime StartTime = workTemplate.StartTime; DateTime EndTime = workTemplate.EndTime; TimeSpan span = EndTime.Subtract(StartTime); int TotalMinutes = (int)span.TotalMinutes; int TimeSpan = (int)workTemplate.SlotGranularity.TotalMinutes; int count = TotalMinutes / TimeSpan; DateTime dateTime = StartTime; DateTime t2 = Convert.ToDateTime((cancelStartEnd.StartTime.ToShortTimeString())); DateTime t3 = Convert.ToDateTime((cancelStartEnd.EndTime.ToShortTimeString())); for (int j = 0; j < count; j++) { DateTime t1 = Convert.ToDateTime((dateTime.ToShortTimeString())); int v1 = DateTime.Compare(t1, t2); int v2 = DateTime.Compare(t1, t3); /* if t1 is less than t2 then result is -1 * if t1 equals t2 then result is 0 * if t1 is greater than t2 then result 1 */ if (!(BookedAppointmentTime.Contains(dateTime.ToShortTimeString()))&&((v1>=0) & v2>=0 )||(v1<0 & v2<0)&&!(BookedAppointmentTime.Contains(dateTime.ToShortTimeString()))) { SlotListDataGroupAll.Add(new SlotListData() { slot = dateTime.ToShortTimeString() }); } dateTime = dateTime.AddMinutes(TimeSpan); } UpdateSlotListData(); } catch(Exception e) { } IsRefreshing = false; } public async Task RefreshGetCancelServiceAsync() { cancelServiceAll = await WebManager.GetCancelServiceAsync(workTemplate.ServiceSlotID); } private async Task getCancelServiceAsync() { foreach (var item in cancelServiceAll) { if(SelectedDate.ToShortDateString()==item.Date.ToShortDateString()) { cancelStartEnd=new CancelStartEnd() { StartTime = item.StartTime, EndTime = item.EndTime }; } } } private async Task getappointmentAsync() { string ServiceSlotIDSelectedDate = workTemplate.ServiceSlotID.ToString() + "," + SelectedDate.ToString(); appointment = await WebManager.GetAppointmentAsync(ServiceSlotIDSelectedDate); BookedAppointmentTime.Clear(); foreach (var item in appointment) { BookedAppointmentTime.Add(item.StartTime.ToShortTimeString()); } } public void UpdateUserPromt() { if (0 == SlotListDataGroupAll.Count) { if (false == NetworkInterface.GetIsNetworkAvailable()) { ShowMessage(EZQResource.SMInternateNotAvailable, true); } } } public void ShowMessage(string Message, bool bIsError = false) { UserPromt = Message; if (bIsError) { UserPromtColor = Color.Red; } else { UserPromtColor = Color.Black; } } public string m_UserPromt = ""; public string UserPromt { get { return m_UserPromt; } set { if (m_UserPromt != value) { m_UserPromt = value; NotifyPropertyChanged(); } } } public Color m_UserPromtColor; public Color UserPromtColor { get { return m_UserPromtColor; } set { if (m_UserPromtColor != value) { m_UserPromtColor = value; NotifyPropertyChanged(); } } } private bool m_isRefreshing = false; public bool IsRefreshing { get { return m_isRefreshing; } set { if (m_isRefreshing != value) { m_isRefreshing = value; NotifyPropertyChanged(); } } } public event PropertyChangedEventHandler PropertyChanged; void NotifyPropertyChanged([CallerMemberName] string name = "") { if (name != "") { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); } } }
}
data ~~~~
DayList:
public class DayList
{
public int serviceSlotID { get; set; }
public string dayString { get; set; }
public string date { get; set; }
public string BindDayDate {
get
{
return string.Format("{0} \n{1}", dayString,DateTime.Parse(date).ToShortDateString());
}
}
}
classWorkTemplate:~~~~
public class WorkTemplate
{
public int WorkTemplateID { get; set; }
public string Name { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public TimeSpan SlotGranularity { get; set; }
public bool Monday { get; set; } public bool Tuesday { get; set; } public bool Wednesday { get; set; } public bool Thursday { get; set; } public bool Friday { get; set; } public bool Saturday { get; set; } public bool Sunday { get; set; } public int ServiceSlotID { get; set; } }
VideoLink:
https://youtu.be/kpKBlJ91wyo
Hi,
For custom renderer reasons I need absolute width of 1st column from Grid.
Grid has 1 row as Auto and 2 columns : 1st as Star and 2nd as Auto.
I want that column's absolute width in my page.
I did try below code:double abswidth = _mainLayout.ColumnDefinitions[0].Width.Value;
but it is returning 1 as I have given width as Star.
I want to compile a c++ procedure to a .so and .a library to use in Xamarin.forms.
and I need to exchange data between them.
should I use a sqlite database? the c++ library write data to the sqlite and the Xamarin.forms read it and re-write to the database and the sqlite re-read it?
but what the db path I created in the Xamarin.forms? which I have to use in c++ library?
Hi everyone !
I am currently using an custom picker with right side icon in my project. This custom picker works fine, i can add icons to my picker right now. But this picker contains border.
I want this custom selector to just have a line under it. Is there a way to do this?
My Custom Renderer code;
Anroid
public class GuncePickerWithRightSideIconRenderer : PickerRenderer { GuncePickerWithRightSideIcon element; protected override void OnElementChanged(ElementChangedEventArgs<Picker> e) { base.OnElementChanged(e); element = (GuncePickerWithRightSideIcon)this.Element; if (Control != null && this.Element != null && !string.IsNullOrEmpty(element.Image)) { Control.Background = AddPickerStyles(element.Image); } } public LayerDrawable AddPickerStyles(string imagePath) { ShapeDrawable border = new ShapeDrawable(); border.Paint.Color = Android.Graphics.Color.Gray; border.SetPadding(10, 10, 10, 10); border.Paint.SetStyle(Paint.Style.Stroke); Drawable[] layers = { border, GetDrawable(imagePath) }; LayerDrawable layerDrawable = new LayerDrawable(layers); layerDrawable.SetLayerInset(0, 0, 0, 0, 0); return layerDrawable; } private BitmapDrawable GetDrawable(string imagePath) { int resID = Resources.GetIdentifier(imagePath.ToLower(), "drawable", this.Context.PackageName); var drawable = ContextCompat.GetDrawable(this.Context, resID); var bitmap = ((BitmapDrawable)drawable).Bitmap; var result = new BitmapDrawable(Resources, Bitmap.CreateScaledBitmap(bitmap, 10, 10, true)); result.Gravity = Android.Views.GravityFlags.Right; return result; } }
iOS
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e) { base.OnElementChanged(e); var element = (GuncePickerWithRightSideIcon)this.Element; if (this.Control != null && this.Element != null && !string.IsNullOrEmpty(element.Image)) { var downarrow = UIImage.FromBundle(element.Image); Control.RightViewMode = UITextFieldViewMode.Always; Control.RightView = new UIImageView(downarrow); } }****
Thanks in advance !