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

Pull down refresh not working on iPhoneX

$
0
0

Hi.
We've got an app (set up mostly in XAML) which uses a list view with PullToRefresh enabled on various pages.
Everything is fine on all devices except iPhone X, where a pull to refresh on the ListView area of the screen actually drags the entire screen down. You can scroll the ListView up and then immediately down in order to activate the pull-to-refresh, but I'm wondering why this is necessary.
Anyone else seen this yet?


Best way to initialize connection to SQL Server

$
0
0

Hello

My app have to retrieve data from a sql server database through a wcf webservice.
But i don't like the way it behave and think there is more optimized solutions.

Now when i open the app, nothing happens with connections, until i open a page which use it (to fill a listview for ex).
Then i have to wait like 1 or 2 seconds for the connection to open and to get data.
But the next pages i open are loaded almost instantly, without that much delay.

What i would like to do, is call the "thing" (would be nice to understand what take so much time. Establishing the connection?) at the launch of the app, when i don't specifically need it instantly, and then all pages will load instantly. To avoid this "first delay".

There is an example of my code. For each View (content page with listview) i have a viewmodel like this one:

 public static readonly EndpointAddress EndPoint = new EndpointAddress("http://IP/Service.svc"); //10.0.2.2 pour emulation android
        private IBienEtreService instance;
        private BienEtreServiceClient client1;

        private static BasicHttpBinding CreateBasicHttp()
        {
            BasicHttpBinding binding = new BasicHttpBinding
            {
                Name = "basicHttpBinding",
                MaxBufferSize = 2147483647,
                MaxReceivedMessageSize = 2147483647
            };
            TimeSpan timeout = new TimeSpan(0, 0, 30);
            binding.SendTimeout = timeout;
            binding.OpenTimeout = timeout;
            binding.ReceiveTimeout = timeout;
            return binding;
        }

        public TemoignageViewModel()
        {
            TemoignagesList = new ObservableCollection<Temoignage>();

            BasicHttpBinding binding = CreateBasicHttp();
            this.client1 = new BienEtreServiceClient(binding, EndPoint);
            this.instance = ((IBienEtreService)client1.InnerChannel);

            client1.GetTemoignageCompleted += ClientOnGetTemoignageCompleted;
            client1.GetTemoignageAsync();
        }

So i guess it's possible to create some kind of "ConnectionClass" and use it each time instead of all this code, not very proper.

Or maybe in App.xaml.cs after this?

public App()
        {
            InitializeComponent();
    // PUT IT HERE
        }

Thanks

DataTemplate Convert C# to XAML

$
0
0

I am using C# code to xaml but it is not convert in XAML Please Help.....
new RightContext();=new LeftContext();=new MainDisplay();= this are all Customize view

var template = new DataTemplate(() =>
{
var rt = new RightContext();
var lt = new LeftContext();
rt.ActionCommand = new Command((object obj) => {
System.Diagnostics.Debug.WriteLine("Hello");
});
lt.ActionCommand = new Command((object obj) => {
System.Diagnostics.Debug.WriteLine("Hello");
});
var mainview = new MainDisplay();
var x = new PanningViewCell(mainview, lt, rt);
return x;
});

Create Custom List View

$
0
0

Hello Xamariniens,
I have to create 3 custom XAML view and i want to add in DataTemplate but it not showing.
So guys i need to a ViewCell with a method in which we can passing 3 argument So guys Please Help me.
var x = new PanningViewCell(new mainview(),new lt(),new rt());
:neutral:
Thanks ...

How to set properties by using xaml

$
0
0

I've this xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:Operacional"
             x:Class="Operacional.MainPage">

    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Button x:Name="btnService" Clicked="Click_Service" Text="Web Service"></Button>
            <!--<Label Grid.Row="0" Margin="10" Text="Aguardando Serviço..." FontSize="22" />-->
            <ListView x:Name="listviewConacts" Grid.Row="1" HorizontalOptions="FillAndExpand" HasUnevenRows="True" ItemSelected="listviewContacts_ItemSelected">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <Grid HorizontalOptions="FillAndExpand" Padding="10">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Label Text="{Binding IdTipoIndicador}" HorizontalOptions="StartAndExpand" Grid.Row="0" TextColor="Blue"  FontAttributes="Bold"/>
                                <Label Text="{Binding ValorPrevisto}" HorizontalOptions="StartAndExpand" Grid.Row="1" TextColor="Orange"  FontAttributes="Bold"/>
                                <Label Text="{Binding ValorRealizado}" HorizontalOptions="StartAndExpand" Grid.Row="2" TextColor="Gray"  FontAttributes="Bold"/>

                                <BoxView HeightRequest="2" Margin="0,10,10,0" BackgroundColor="Green" Grid.Row="3" HorizontalOptions="FillAndExpand" />
                            </Grid>
                        </ViewCell>

                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </Grid>
        <ActivityIndicator x:Name="ProgressLoader" IsRunning="True"/>
    </Grid>
</ContentPage>

i'm having problem to consume a post web service. So i want to try out but in release mode. I need to set 3 properties above. Below my model class.

public class IndicadorPost
    {
        public int IDUsuario { get; set; }
        public int TipoIndicador { get; set; }
    }
    public class TipoIndicador
    {
        public decimal ValorPrevisto { get; set; }
        public decimal ValorRealizado { get; set; }
        public IndicadorPost indicadorPost { get; set; }
    }

    public class Indicador
    {
        public List<TipoIndicador> tipoIndicador { get; set; }
    }

and here is my service class

public async Task<Indicador> PostIndicador(IndicadorPost indicador)
        {
            try
            {
                client = new HttpClient();
                string url_base = $"http://10.200.0.50/B2BService/B2BService.svc/ObterIndicador";
                var uri = new Uri(string.Format(url_base));
                var data = JsonConvert.SerializeObject(indicador);
                var content = new StringContent(data, Encoding.UTF8, "application/json");

                HttpResponseMessage response = await client.PostAsync(uri, content);

                var responJsonText = await response.Content.ReadAsStringAsync();

                return JsonConvert.DeserializeObject<Indicador>(responJsonText);
            }
            catch (Exception ex)
            {                
                string er = ex.Message;
                return null;
            }
        }

and here click button to call service class

private async void Click_Service(object sender, EventArgs e)
        {
            IndicadorPost indPost = new IndicadorPost();
            indPost.IDUsuario = 1;
            indPost.TipoIndicador = 2;

            DataService dataService = new DataService();

            string jvalue = "{\"IDUsuario\":1,\"TipoIndicador\":2}";
            try
            { 
                await dataService.PostIndicador(jvalue);  

            }
            catch(Exception ex)
            {
                string er = ex.Message;
            }
        }

How do i do to show listview in the xaml file? I'm not in debug mode, only release. What do i return, how do i bind these properties?
i'm reading this link: https://developer.xamarin.com/guides/xamarin-forms/xaml/bindable-properties/

No NavigatioBar on the Master Section of MasterDetailPage in UWP

$
0
0

Hello Eveyone
Great to see a lot of people are collaborating on this forum .
I'm a pretty new with Xamarin and trying to build up a application from a week ago.
I am using a MasterDetailPage and setting the master as a Navigation ( ContentPage as the child ).
My problem here is i am not able to see any Navigationbar at the Master Section. It looks empty.Whereas the Detail is set as a NavigationPage ( TabbedPage as the child ) has seen it properly without any problems.

Also note my masterBehaviour is set to Split and i'm trying with UWP platform.

Please provide me some inputs on why there is a mismatch.

Thanks in Advance.
Vsh

DateSelected event on corcav behaviors with Min&Max date bindings

$
0
0

Hey guys, need a small help!
I'm getting error while using corcav behaviors with for xamarin datepicker's DateSelected event. I'm applying MinDate&Maxdate for datepicker.
If i remove the bindings of MinDate&MaxDate then it is not throwing any error. Applying MinDate&Maxdate triggering DateSelected event so it is looking for command that has bind to this event. I think, Initially this command was unreachable because we set behaviors after Min&Max Date binding. I don't know the exact reason. Is there any ways to overcome this situation?

Compile exception with Xamarin Forms app migrated to .NET Standard 2.0 with sqlite

$
0
0

I have just migrated my Xamarin Forms project to .NET Standard 2.0 and am having trouble getting the project to compile. I continue to get the exception "Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'SQLite-net, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?"

My solution is set up as such;

  • Forms Project - .NET Standard 2.0 Lib
  • Core Project - .NET Standard 2.0 Lib
  • DataProject (using sqlite-net-pcl) .NET Standard 2.0 Lib
  • Android
  • iOS
  • UWP

When running the Android project I get the above error. I am not certain what I am doing wrong (I am sure it is something obvious) and would appreciate some advice and guidance.

Thanks all!


Bug in DisplayActionSheet, when user touches outside to cancel

$
0
0
await DisplayActionSheet ("TEST ACTION SHEET", null, null, "Action A", "Action B");

Causes "index beyond bounds" exception when the user touches outside the popup area. Touching outside means cancel. To fix, provide a cancel text:

var userChoice = await DisplayActionSheet ("TEST ACTION SHEET", "Cancel", null, "Action A", "Action B");

But the "Cancel" text doesn't appear in the popup on iOS, which is fine, except I would prefer to test for null rather than userChoice=="Cancel".

(Also, it's not clear where bugs should be reported.)

Bind an Entry to an int property in code behind

$
0
0

I am trying to bind and Entry to an int property, but having trouble.

I have this data class

public class MyData
{
    public string MyString { get; set; }
    public int MyInt { get; set; }
}

I have this value converter

public class StringIntConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value is string s)
            return int.TryParse(s, out var res) ? res : 0;
        return ((int) value).ToString();
    }
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value is string s)
            return int.TryParse(s, out var res) ? res : 0;
        return ((int)value).ToString();
    }
}

and am trying to bind my label name Value

var myData = new MyData();
Value.SetBinding(Entry.BindingContextProperty, myData.MyInt, new StringIntConverter(), null);

but it says can't convert MyData.MyInt to a string

Access denied on Android when creating a folder

$
0
0

I have a Xamarin.Forms program which creates and then uses a directory on Android. This worked on my Nexus but is getting "Access denied" on my Samsung.

Here is the code:

            if ( !Directory.Exists( Path.Combine( ( string ) global::Android.OS.Environment.ExternalStorageDirectory, "MyFolder" ) ) )
            {
               Directory.CreateDirectory( Path.Combine( ( string ) global::Android.OS.Environment.ExternalStorageDirectory, "MyFolder" ) );
            }

NB: I've also tried using ...ExternalStorageDirectory.AbsolutePath -- same results.

Android TimePicker OK-Button pressed event

$
0
0

Hello,
how do I catch the OK-Button pressed Event in Android TimePicker custom renderer?

    public class TimerTimePickerRenderer : TimePickerRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.TimePicker> e)
        {
            base.OnElementChanged(e);

            if (Control != null)
            {
                //When OK Button is pressed:
                //MessagingCenter.Send("Droid", "TimeChanged")
            }
        }
    }

How to get an Android splash screen implemented using a 9-patch image?

$
0
0

I am trying to replace the .png that I am using for a splashscreen in the Android project of my Xamarin.Forms app with a 9-patch image so that the core of the image remains at its set size regardless of screen size, but with the edges being expanded to fill the screen (or that is the hope).

My LaunchActivity class has the following defined:

[Activity(
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize,
Icon = "@drawable/launchericon",
Label = "MyApp",
LaunchMode = LaunchMode.SingleInstance,
MainLauncher = true,
NoHistory = true,
ScreenOrientation = ScreenOrientation.FullSensor,
Theme = "@style/Theme.Splash",
WindowSoftInputMode = SoftInput.AdjustPan)]

I have a styles.xml that contains the following:

<?xml version="1.0" encoding="utf-8" ?>
<resources>
    <style name="Theme.Splash" parent="android:Theme">
        <item name="android:windowBackground">@drawable/splash</item>
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>

I have a splash.png file in each of my drawable folders. Each has a one pixel transparent border, but with black pixels at positions (0,0), (0,1) and (1,0). I did also have black pixels in the final row and column, but have removed those whilst investigating what is happening.

I can see (as a result of making each image unique) that the splash.png in the following folder is being painted on startup:
G:\tfs\MyApp\MyApp\MayApp.Android\Resources\drawable-hdpi\

However, the image is being expanded to fill the screen, with the aspect ratio not maintained.

Can anybody advise as to what might be wrong, or point me to a sample that shows this working please? Or am I completely misunderstanding what 9-patch images do?

Is it possible to create a side menu drawer along with tab bar controller in Xamarin Forms.

$
0
0

Hey Guys, I have been trying to implement the screen attached below which contains a side menu and a bottom tabbar on every screen. My Question is it possible to show the bottom tabbar on every screen.

I am using the library BottomNavigationBar for Tabbar layout on iOS and Android which works fine. However, I am unable to add a Side Navigation Menu to tabbar. I would appreciate if I get some sample code on GitHub for reference or some idea how this can be achieved.

How to update listview viewcell label data?

$
0
0
public EmployeeListPage()
{
  ...
  employees.Add(new Employee{ DisplayName="Rob Finnerty"});
  employees.Add(new Employee{ DisplayName="Bill Wrestler"});
  employees.Add(new Employee{ DisplayName="Dr. Geri-Beth Hooper"});
  employees.Add(new Employee{ DisplayName="Dr. Keith Joyce-Purdy"});
  employees.Add(new Employee{ DisplayName="Sheri Spruce"});
  employees.Add(new Employee{ DisplayName="Burt Indybrick"});
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:constants="clr-namespace:XamarinFormsSample;assembly=XamarinFormsXamlSample"
x:Class="XamarinFormsXamlSample.Views.EmployeeListPage"
Title="Employee List">
  <ListView x:Name="EmployeeView">
    <ListView.ItemTemplate>
      <DataTemplate>
        <TextCell Text="{Binding DisplayName}" />
      </DataTemplate>
    </ListView.ItemTemplate>
  </ListView>
</ContentPage>

when i create a listview,i want dynamic set DisplyName data,example set Rob Finnerty to Rob Finnerty 2,how to solution?


Temporary files names are way too long

$
0
0

Looks like not only me but a lot of other people having problems with Xamarin build due to the max path limit.
We force to move a solution folder to the top, use shorter subfolders names... - It doesn't help to keep projects well organized.
Look at the temp file generated by iPhone project:
TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
it is 63 chars long. You are taking nearly 25% of the max path.
Use Path.GetRandomFileName() - name generated by it doesn't look as "nice" as you version but it's short.

XF 2.3.4 compatible with Android 8.1.0?

$
0
0

I have an existing app built with XF 2.3.4. I just upgraded my Android device to 8.1.0 and I am seeing LOTS of crashes. If I run the same app on my older Android 7.1.2 device, everything is good. Are there bugs in Android 8.1.0 itself or do I have to upgrade my XF to support 8.1.0?

How to create Check box group, radio button group and multi line text box

$
0
0

Hi,

Can any one suggest me to create Checkbox group, radio button group and multi line text box in xamarin forms?

Multiple Windows with Xamarin.Forms

$
0
0

Hi,

I'm having a hard time understanding the best way to create multiple windows with a Xamarin.Forms application for MacOs and Windows that I'm creating. Ideally, I would like it to be a cross platform solution but I haven't been able to find or figure out the best way. Any idea if this is even possible?

Thanks in advance,
Steve

How to create a Tabbed page where the main page is no part of the tabbed toolbar?

$
0
0

I want the home screen to be a tabbed page. from the home screen you can go to the tab for settings, for messages, and for photos. But I don't want the home screen to be a tab. I think technically it needs to be a tab. But is there a way to hide its tab in the tab bar? For example, in the tab bar all I see is Settings, Message, Photos.

Thanks

Viewing all 58056 articles
Browse latest View live


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