Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 89864 articles
Browse latest View live

Publish IOS App From visual Studio Directly or Indirectly

$
0
0

I have developed an IOS App using Xamarin.Form From Visual Studio 2017 on Windows 10 and a mac book is connected in same network.
I have also purchase an Apple Developer Program Account. my ios app is running perfectly in IOS Simulator.
now i want to publish ios app to AppStore. i don't have Iphone Device. Is Iphone Required for publishing IOS App to App Store or MacBook is sufficient.

Please tell me how can i Publish Directly or indirectly from Visual studio Or What is standard procedure to publish App to App Store.

Thanks
Prem Shah
+9779851048402


Not Refreshing Spesific Label While Binding ObservableCollection Listview in Xamarin & MVVM

$
0
0

My INotifyPropertyChanged Code:

public class Zicker : INotifyPropertyChanged
{
public class MyClass
{
public string HeyName { get; set; }
public string HeySurname { get; set; }
public int HeyAge { get; set; }
}

    public event PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged([CallerMemberName] string name = null)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(name));
        }
    }

    private ObservableCollection<MyClass> _yourList = new ObservableCollection<MyClass>();
    public ObservableCollection<MyClass> YourList
    {
        get
        {
            return _yourList;
        }
        set
        {
            _yourList = value;
            RaisePropertyChanged("YourList");
            RaisePropertyChanged("BindMeLabel");
        }
    }

    public int BindMeLabel
    {
        get { return _yourList.Sum(a => a.HeyAge); }
    }

    public void WonCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        RaisePropertyChanged("BindMeLabel");
    }

    public List<string> heresamplenames = new List<string> { "Mohamed", "Zaran", "Ivan" };
    public List<string> heresamplesurnames = new List<string> { "Pakou", "Simmone", "Zagoev" };
    public List<int> heresampleages = new List<int> { 17,33,50 };

    public Zicker()
    {
        ObservableCollection<MyClass> vs = new ObservableCollection<MyClass>();
        for (int i = 0; i < 3; i++)
        { vs.Add(new MyClass { HeyName = heresamplenames[i], HeySurname = heresamplesurnames[i], HeyAge = heresampleages[i] }); }
        YourList = vs; YourList.CollectionChanged += WonCollectionChanged;
    }
}

My XAML.CS

    public MainPage()
    {
        InitializeComponent();
        BindingContext = new Zicker();
    }

My XAML:

<ContentPage.Content>



<ListView.ItemTemplate>


<ViewCell.View>

<Grid.ColumnDefinitions>



</Grid.ColumnDefinitions>



</ContentPage.Content>

My Problem:

In List, there are three names, surnames, and ages. At the bottom, there is also a label which should be shown as the sum of Ages collection.

When the UI is starting, Label is working well. But, if I try to change any Ages entries, there is a big problem with the binding label.

How to tell when the last row of a dxGrid:GridControl becomes visible?

$
0
0

With a GridControl, how can I trigger an event when the last row of the list becomes visible?

I'm using a GridControl to display a list of data and check boxes, and I want to trigger an event when the user scrolls down far enough for the last row of data to become visible, but I'm having trouble figuring out how to do it. Can someone please point me in the right direction? This is how I'm declaring my list:

<dxGrid:GridControl x:Name="dxDataList" ItemsSource="{Binding myDataList}">
      <dxGrid:GridControl.Columns>
          <dxGrid:SwitchColumn FieldName="bIsChecked" Caption="Completed"/>
          <dxGrid:TextColumn FieldName="CheckBoxText" Caption="Task"/>
      </dxGrid:GridControl.Columns>
</dxGrid:GridControl>

Introduce TEditor(a HTML rich text editor in Xamarin.Forms)

Picker not updating selected item from MVVM

$
0
0

I have a form like below with picker control. Its source is in MVVM's observableCollection. Depending if it's existent Process or new one, _this object is created from scratch or set to object passed in constructor.
All works good, meaning picker get populated and _this contains appropriate object. The thing is, though, if _this is existent object with specified Type property, appropriate item in picker won't get selected automatically when form is loaded. I mean I see picker's title instead of item that's supposed to be selected. I'm wondering what might be wrong. Any ideas?

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="TestZXing.ProcessPage">
    <ContentPage.Content>
        <StackLayout VerticalOptions="Center">
            <Picker
                x:Name="cmbActionTypes"
                HorizontalOptions="Center" 
                Title="Wybierz typ zgłoszenia"
                ItemsSource="{Binding ActionTypes}"
                ItemDisplayBinding="{Binding Name}"
                SelectedItem="{Binding Type, Mode=TwoWay}"
                />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

There's a MVVM model behind it:

public class ProcessPageViewModel: INotifyPropertyChanged
    {
        public ObservableCollection<ActionType> ActionTypes { get; set; }
        private Process _this { get; set; }

        public ProcessPageViewModel()
        {
            _this = new Process();
            IsSaved = false;
            Initialize();
        }

        public ProcessPageViewModel(Process Process)
        {
            _this = Process;
            Initialize();
        }

        private async void Initialize()
        {
            try
            {
                ActionTypes = new ObservableCollection<ActionType>();
                ActionTypesKeeper keeper = new ActionTypesKeeper();
                await keeper.Reload();
                foreach (ActionType at in keeper.Items)
                {
                    ActionTypes.Add(at);
                }
            }catch(Exception ex)
            {
                throw;
            }

        }

        private ActionType _type { get; set; }

        public ActionType Type
        {
            get
            {
                if(ActionTypes.Where(at => at.ActionTypeId == _this.ActionTypeId).Any())
                {
                    _type = ActionTypes.Where(at => at.ActionTypeId == _this.ActionTypeId).FirstOrDefault();
                }
                return _type;
            }
            set
            {
                if (_type != value)
                {
                    _type = value;
                    _this.ActionTypeId = _type.ActionTypeId;
                    _this.ActionTypeName = _type.Name;
                    OnPropertyChanged();
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged([CallerMemberName] string name = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
    }

Animation when changing MainPage of the application

$
0
0

I am using a MasterDetail template and I also have a login page. In my app when I am logged out I have set:

MainPage = new LoginPage();

When I will successfully log in I am just changing MainPage to MasterDetailNavigation like this:

MainPage = new MasterDetailNavigation();

However, there is no animation (page transition) when I am changing MainPage. How can I add it? It would be great to have i.e. the same animation which is when we are doing:

Navigation.PushAsync(new SomePage())

How can I achieve this animation?

Value cannot be null. Parameter name: type

$
0
0

Not sure what changed, but now when I build I get this error on every XAML file in my project. Has anyone ran into this issue before? Tried all of the usual fixes - del bin/obj, restart, clean rebuild, downgrade Forms...

Picker don't show anything

$
0
0

Hi all togehter,
i have serious problems with the Picker:

    <Picker BackgroundColor="Red"
                      Title="Select Job" 
                      ItemsSource="{Binding Projects}"
                      SelectedItem="{Binding SelectedProject,Mode=TwoWay}"
                      ItemDisplayBinding="{Binding SelectedProject.ProjectId}"                                                      
      ></Picker>

My ViewModel:

Project _selectedProject;
    public Project SelectedProject
    {
        get => _selectedProject;
        set => SetProperty(ref _selectedProject, value);
    }

    ObservableCollection<Project>  _projects;
    ObservableCollection<Project> Projects
    {
        get { return _projects; }
        set { SetProperty(ref _projects, value); }
    }

var items = new ObservableCollection();

var projects = (IEnumerable)parameters["Projects"];

foreach (Project project in projects)
{
items.Add(project);
}
Projects = items;
SelectedProject = Projects.FirstOrDefault();

My PickerControl don't Show anything, no list of items, definitly nothing....

Databinding to other Controls like TableView works, i just remove them for Debugging

Any idea
Peter


List view consuming lots of memory on scrolling using xamarin forms for UWP.

$
0
0

We are using Xamarin forms version 2.5.1, In our app, we are using list view for displaying tabular data for that I am using view cells inside data template.
My view cell consists of grid layout that contains 40-45 columns and to display data on the UI I am using 40-45 labels per row.
The issue that I am facing currently is that when I have large data say 2000 records, so when the user scrolls it takes time to render new records to UI that is first black screen comes and then slowly data gets populated to different rows of list view.
Also, memory consumption increases on scrolling up and down the list view. I have also used the Listview Cached strategy to Recycle element but still no improvement. On profiling, I found that new instances of labels keep on getting created which leads to more rendering time and high memory consumption. So how can we optimize the performance of list view so that it works well with large data. Our target platform is Windows 10 UWP and IOS

Is anyone actually using the geofence plugin in production?

$
0
0

I have created an app that uses the geofence plugin (https://github.com/domaven/xamarin-plugins/tree/master/Geofence) to notify users when they enter/exit certain locaitons.

It works to some extent, but there are a few problems:
-When monitoring location exit, iOS users experience numerous false exit notifications, especially when moving around inside the location perimeters. Also if moving outside the location, when phone wakes up after being inactive, one can get 3-4 notifications about exiting the location, even if the user is far away
-All proper exit notifications (not the fake ones) are displayed twice on iOS
-On Android, some users don't get notifications at all, especially if the app is in background or closed

I am thinking about moving to the acr geofencing plugin (https://github.com/aritchie/geofences/tree/master/), but it is a bit of work. So I am wondering if:

1.Does anyone else have experience with either of these plugins in production?
2.Anyone else have experience with same problems that I am facing?

It's weird that nobody else seems to have problems. I was a newbie to Xamarin when writing the app, I am thinking of creating a small sample. Maybe I have made mistakes, although I have been going through my code several times without finding any. Maybe nobody is actually using the geofence plugin for other than playing around....

Appreciate any insights on this.

Navigation only works in Debug and Release mode?

$
0
0

Hi All,

i have discovered a very strange problem or behavior of xamarin.forms for me. The problem is navigation only works in debug or release mode, as soon as I create an APK (archive) navigation doesn't work anymore. I cut my code down to a minimun (only looks big by the CommandCanExecute part) I have no idea why this run fine in debug and release mode but if its packed up it wont, i don't even get an exception thrown :(
`
// App
public App () {
InitializeComponent();
MainPage = new NavigationPage(new Views.MainPage());
}

// MainPage
public partial class MainPage : ContentPage {
MainPageViewModel viewModel;
public MainPage() {
InitializeComponent();
viewModel = new MainPageViewModel(this, Navigation, ScrollViewLog);
BindingContext = viewModel;
}
}

// MainPageViewModel
public class MainPageViewModel : INotifyPropertyChanged {

// property
private bool openOptionsPasswordCheckCommandCanExecute = true;
public bool OpenOptionsPasswordCheckCommandCanExecute {
    get { return openOptionsPasswordCheckCommandCanExecute; }
    set {
        openOptionsPasswordCheckCommandCanExecute = value;
        ((Command)OpenOptionsPasswordCheckCommand).ChangeCanExecute();
    }
}

// command
public ICommand OpenOptionsPasswordCheckCommand { get; private set; }

// fields
    private INavigation navigation;

// construct
public MainPageViewModel(INavigation navigation) {
    this.navigation = navigation;
    OpenOptionsPasswordCheckCommand = new Command(async () => await OpenOptionsPasswordCheckCommandAction(), () => OpenOptionsPasswordCheckCommandCanExecute);
}

// the navigation
private async Task OpenOptionsPasswordCheckCommandAction() => await NavigateToOptionsCheckPassword();
public async Task NavigateToOptionsCheckPassword() => await navigation.PushAsync(new OptionsPasswordCheck());

// even if I not use the passed Navigation object it won't work -->
// Application.Current.MainPage.Navigation.PushAsync(new OptionsPasswordCheck()); // navigation.PushAsync(new OptionsPasswordCheck()

}
`

Xamarin.Forms.Maps crashing on Android

$
0
0

Hi folks,
My Xamarin.Forms app crashes when trying to display a map on Android. Here's my code:

            var map = new Map(
                MapSpan.FromCenterAndRadius(
                        new Position(0,0), Distance.FromMiles(0.3)))
            {
                IsShowingUser = true,
                HeightRequest = 100,
                WidthRequest = 960,
                VerticalOptions = LayoutOptions.FillAndExpand
            };
            var stack = new StackLayout { Spacing = 0 };
            stack.Children.Add(map);
            Content = stack; 

I can't figure out what the issue is because it functions fine on iOS. It's not an API key issue, as I'm not even getting a grey box (I'd love for it to even reach that point) - it just crashes whenever I open the page.

Any help would be greatly appreciated, I've been tearing my head out with it for a couple of days now.

Style FontSize OnPlatform in Xaml

$
0
0

Hi everybody, i'm looking for a way to change the fontsize of all my labels with a style defined in App.xaml (XF 1.3).

But i don't find any way to make it works.
Note : i want to make it with xaml in app.xaml

<Style x:Key="Titre"
       TargetType="ctrls:Label">
    <Setter Property="FontAttributes"
            Value="Bold"/>
    <Setter Property="ctrls:Label.FontSize">
        <Setter.Value>
            <OnPlatform x:TypeArguments="x:Double">
                <OnPlatform.iOS>18</OnPlatform.iOS>
                <OnPlatform.Android>18</OnPlatform.Android>
                <OnPlatform.WinPhone>26</OnPlatform.WinPhone>
            </OnPlatform>
        </Setter.Value>
    </Setter>
</Style>

The bold attribute worked but no luck with fontsize.

I've tryed different solutions :
<OnPlatform.iOS>
18</x :Double>
</OnPlatform.iOS>

Even this line doesn't work :
<Setter Property="FontSize" Value="30"/>

I can declare style for everything except fontsize. What am i doing wrong ?

(please Xamarin Team, do something for the code we paste here : there are always some text hidden, some lines missing etc. I don't know how the hell you came up with such a weird behavior but i d rather prefer simple text without formating that half the code i paste. We are not here to edit our message 10 times. I spend more time editing my code than writing the entire message. Thank you guys)

Exemple : my code OnPlatform.iOS x double 18 shows half the code in my browser. So people will think i don't care about this post because there are code missing but no. The text is just hidden for no reason.

Is there a way to find a child element of a certain type like Xamarin.forms.label inside a Page

$
0
0

This is my Custom page's XAML

            > <?xml version="1.0" encoding="utf-8" ?>
> <customcontrols:RC_Page xmlns="http://xamarin.com/schemas/2014/forms"
>              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
>              xmlns:images="clr-namespace:RecoveryConnect_Mobile_PCL.Resources.Images;assembly=Blah_PCL"
>              x:Class="Blah.Views.Splash.Page_Splash"
>               xmlns:customcontrols="clr-namespace:Blah.CustomControls;assembly=RecoveryConnect_Mobile_PCL"
>             Title="Splash"
>              BackgroundColor="White">
>   
>     <Image
>               Source="{x:Static images:AppResources.Image_Splash}"
>               Aspect="AspectFit" />
>   
> </customcontrols:RC_Page>

This is the custom RC_Page's inherting off of ContentPAge.

public class RC_Page:ContentPage
{

            this.BackgroundColor = Color.Black;
            

        
    }
}

}

Is there a way I can do something like this.getChildOfType(Image);. That will give me a result of the Image element in the XAML?

  • My goal is to collect all the child elements in the page, so that I can apply some styling to them at runtime based on their type.
  • PS:- I do not want to do dynamic Resource Binding, but rather centralize everything at the RC_Page level itself.

Thanks

System.NullReferenceException: Object reference not set to an instance of an object

$
0
0

im using App Center to collect insights about the app. im not using MainPage as my entry page.
In recieving this error

PageUtilities.GetCurrentPage (Xamarin.Forms.Page mainPage)
System.NullReferenceException: Object reference not set to an instance of an object
1
PageUtilities.GetCurrentPage (Xamarin.Forms.Page mainPage)
2
PrismApplicationBase.OnSleep ()
3
Application.SendSleepAsync ()
4
FormsAppCompatActivity+d__32.MoveNext ()
5
ExceptionDispatchInfo.Throw ()
6
TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task)
7
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task)
8
TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task)
9
TaskAwaiter.GetResult ()
10
FormsAppCompatActivity+d__28.MoveNext ()
11
ExceptionDispatchInfo.Throw ()
12
AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state)
13
SyncContext+<>c__DisplayClass2_0.b__0 ()
14
Thread+RunnableImplementor.Run ()
15
IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this)
16
(wrapper dynamic-method) System.Object:1ccf4a28-d5de-41dd-ad05-219c61425ae0 (intptr,intptr)


Custom renderer not appearing in listview datatemplate...anyone know why?

$
0
0

I wrote a custom renderer to handle gestures (long press in particular). Debugging the code, the custom renderer is not hitting the breakpoints when used inside a datatemplate/viewcell (as shown in the following snippet)...the Label with a background color of Orange does appear, but the local.LabelExt does not appear (not the text or the background color). The background colors are only there to assist in my troubleshoot efforts.

Xaml:
<?xml version="1.0" encoding="utf-8" ?>

<ContentPage.ToolbarItems>

</ContentPage.ToolbarItems>

<ContentPage.Content>


<ListView.ItemTemplate>


<ViewCell.ContextActions>


</ViewCell.ContextActions>

                        </Label>
                        <local.LabelExt x:Name="lblAuditSetName" 
                                    Text="{Binding Name}" 
                                    Style="{StaticResource BaseLabelStyle}"
                                    HorizontalOptions="StartAndExpand" 
                                    VerticalOptions="Start" 
                                    VerticalTextAlignment="Start" 
                                    HorizontalTextAlignment="Start" 
                                    FontAttributes="Bold"                                           
                                    FontSize="14"
                                    TextColor="Black"
                                    Margin="5,0"
                                    LongPress="OnLongPress"
                                    CommandParameter="{Binding .}"
                                    BackgroundColor="Red">
                        </local.LabelExt>

Extended class:
using System;
using Xamarin.Forms;

namespace NotWorkingNS
{
public class LabelExt : Label
{

region Events

public delegate void LongPressDelegate(object sender, EventArgs e);
public event LongPressDelegate LongPress;

endregion Events

#region Properties
public const string CommandParameterPropertyName = "CommandParameter";
public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create
    (CommandParameterPropertyName, typeof(object), typeof(LabelExt), new object());
public object CommandParameter
{
    get => (object)GetValue(CommandParameterProperty);
    set => SetValue(CommandParameterProperty, value);
}

public const string TagPropertyName = "Tag";
public static readonly BindableProperty TagProperty = BindableProperty.Create
    (
        propertyName: TagPropertyName,
        returnType: typeof(object),
        declaringType: typeof(LabelExt),
        defaultValue: new object()
    );
public object Tag
{
    get => (object)GetValue(TagProperty);
    set => SetValue(TagProperty, value);
}
#endregion Properties

public EventHandler LongPressActivated;

public void HandleLongPress(object sender, EventArgs e)
{
    //handle long press event
    LongPress?.Invoke(sender, new LabelExtEventArgs(e, CommandParameter));
}

}

public class LabelExtEventArgs : EventArgs
{
public object CommandParameter { get; set; }
public EventArgs EventArgs { get; set; }

public LabelExtEventArgs(EventArgs e, object CommandParameter)
{
    EventArgs = e;
    this.CommandParameter = CommandParameter;
}

}

}

Custom Renderer:
using System;
using Foundation;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using NotWorkingNS;

[assembly: ExportRenderer(typeof(LabelExt), typeof(NotWorkingNS.iOS.LabelExtRenderer))]

namespace NotWorkingNS.iOS
{
public class LabelExtRenderer : LabelRenderer
{
LabelExt view;
public LabelExtRenderer()
{
this.AddGestureRecognizer(new UILongPressGestureRecognizer((longPress) => {
if (longPress.State == UIGestureRecognizerState.Began)
{
view.HandleLongPress(this, new EventArgs());
}
}));
}

protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
    base.OnElementChanged(e);

    if (e.NewElement != null)
        view = e.NewElement as LabelExt;
}

}

}

XF3 solution - iOS - FileNotFound Images.imageset/Contents.json

$
0
0

I haven't dealt with the iOS asset catalog stuff before.
All new XF3 solution. I've added all the images wanted by the Assets.xcassets/AppIcon pane (and what a pain that is).
So I no longer get an error for image120.png not found, etc.

Now I get an error for Images.imageset/Contents.json not found. ANd I agree. When I look on the build mac there is no such directory or file.

So... Now what? What is it looking for to create that Images.imageset? Do I have to add images to an image set whether I have any or not? Does it just not work if you don't have at least a set defined?

Well... Let's try that.
Now it complains there is no Images blah blah. I'm thinking that at one time there was an Images catalog that got deleted... but not fully deleted... so some file someplace thinks its still there. Each new Images catalog is the next number up. So I'm always missing one.

Does anyone know where the list of these catalogs lives so I can manually edit it?

After updating XF to 3.0 WebView full screen modus shows white screen ONLY for Android devices

$
0
0

I just updated my App to XF 3.0 in Xamarin Forms (PCL) and strangely suddenly a page where there is a Full Screen WebView is loaded shows a white screen ONLY for Android Devices (iOS does work -> Screenshot 3).

Loading the YouTube video on the Webview works fine (Screenshot 1), after clicking the Play button in the Center a WHITE screen shows up and the video will not be displayed (Screenshot 2).

Is there a bug for Android?

I did not show the source code because it is just a simple YouTube link loaded in the WebView.



Mono's Support with cipher suites

$
0
0

In one of the apps the app-server handshake is failing to occur where as another similar app works well.

Both the apps are pointing to 2 different servers having SSL enabled on the server. It is observed that both the servers use different cipher suites.

Fails on - TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, 256 bits, TLS 1.2

Works on - TLS_RSA__WITH_AES_256_CBC_SHA, 256 bits, TLS 1.2

Exception received on the app -

System.Net.WebException: Error: SecureChannelFailure (The authentication or decryption has failed.)

I found the below link which mentioned about Mono's support which ECDHE/DHE cipher suite.

Link - https://bugzilla.xamarin.com/show_bug.cgi?id=42805

Please guide me to resolve this.

Endless problems...

$
0
0

Why there is always problem with Xamarin? Fresh project and:
1. No intelisense for XAML
2. Controls are inaccesible from code (I had to add [XamlCompilation(XamlCompilationOptions.Compile)] and BindingContext = new MainPage();
to get this work)
3. After project creation you have to build it to restore nuget packages
4. Xamarin Live Preview crashes without any error with only Label control. I removed device and added again, still same problem
5. Sometimes it looks for latest ver. of Android SDK even if simulators are for installed ver. of SDK. You have to change a target API or install latest

How you guys are able to work with Xamarin? Maybe it's only me. I'm not interesed in Java. Can someone help me?

PS.
This project is a start project with label control in center. What would happen if I wanna do something more than showing a text in center of screen... -.-'

Viewing all 89864 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>