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

Exception: Only the original thread that created a view hierarchy can touch its views

$
0
0

The code below works on Windows Phone but when running on Android I am getting the following exception : android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

        public ButtonLoggerPage()
                {
                    // Create the Button and attach Clicked handler.
                    Button button = new Button
                    {
                        Text = "Log the Click Time"
                    };

                    button.Clicked += OnButtonClicked;
                    opusClient.LoginCheckCompleted += OpenReadLogincheck;

                    this.Padding = new Thickness(5, Device.OnPlatform(20, 0, 0), 5, 0);

                    tbSyncItemLbl = new Label { };

                    // Assemble the page.
                    this.Content = new StackLayout
                    {
                        Children = { button,new ScrollView { VerticalOptions = LayoutOptions.FillAndExpand,

                        BackgroundColor = Color.Gray,
                        Content = loggerLayout}
                        }
                    };
                }

        void OnButtonClicked(object sender, EventArgs args)
            {

                        loginCheck();

            }

     public void loginCheck()
            {
                try
                {


                    client.LoginCheckAsync(username, password);
                }
                catch (Exception e)
                {

                    receiveErrors = 22;
                }
            }

    void OpenReadLogincheck(Object sender, LoginCheckCompletedEventArgs e)
    {


                if (e.Result != null)
                {
                    LoginStatus = e.Result.Value;
                    if (e.Result == 1)
                    {
                        addMessage("Login Succeeded", Direction.Download);

                    }

}
}

        public enum Direction { Upload, Download, DownloadFailed, UploadFailed };

             public void setSyncItem(string itemName, Direction dir)
                    {
                        tbSyncItemLbl.Text += itemName +" " + Environment.NewLine;


                        if (dir == Direction.Download)
                        {
                            this.tbSyncItemLbl.TextColor = Color.FromHex("B5DF26");
                        }
                        else if (dir == Direction.Upload)
                        {
                            this.tbSyncItemLbl.TextColor = Color.FromHex("527EA5");
                        }
                        else if (dir == Direction.DownloadFailed)
                        {
                           this.tbSyncItemLbl.TextColor = Color.FromHex("FF0000");
                        }
                        else if (dir == Direction.UploadFailed)
                        {
                           this.tbSyncItemLbl.TextColor = Color.FromHex("FF0000");
                        }

                        this.tbSyncItemLbl.YAlign = TextAlignment.Center;

                    }

         private void addMessage(string item, Direction dir)
                {
                          setSyncItem(item, dir);
                        loggerLayout.Children.Add(tbSyncItemLbl);                   
                }

        Label tbSyncItemLbl ;

after installation - vs Xamarin create an Empty solution without the projects

$
0
0

just after clean windows 10 installation, installing and reInstalling visual studio 2017 (cuz my old solution wouldn't run no longer).
cant create a new xamarin solution or the run me old working solution.




Multiple devices

$
0
0

Im new to Xamarin, but when I create apps I want them to be presentable in multiple devices. What are your recomendations when it comes to "responding" to multiple devices? Like, should I use RelativeLayout instead of StackLayout to achieve this?

App crashes when built in release but works fine in debug

$
0
0

I am currently running into an issue where my debug build of an app functions just fine but when I build it out in release, the app crashes. Below is the error given. One thing someone suggested was to look at the linking option. I have and both builds are linking sdk assemblies only.

04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): [Error] Exception { Message: "CurrentDomainOnUnhandledException", Data: [], InnerException: RuntimeException { JniPeerMembers: XAPeerMembers { ManagedPeerType: Java.Lang.RuntimeException, JniPeerTypeName: "java/lang/RuntimeException", JniPeerType: JniType { PeerReference: JniObjectReference { Handle: IntPtr { }, Type: Global, IsValid: True } }, InstanceMethods: JniInstanceMethods { }, InstanceFields: JniInstanceFields { }, StaticMethods: JniStaticMethods { }, StaticFields: JniStaticFields { } }, StackTrace: "
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): --- End of managed Java.Lang.RuntimeException stack trace ---
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.testco.android.testapp/md52383f3bfe5cb92264ccfe16c72588a4e.MainActivity}: android.content.res.Resources$NotFoundException: File ModernHttpClient.Android from drawable resource ID #0x7f080051: .xml extension required
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.app.ActivityThread.-wrap11(ActivityThread.java)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.os.Handler.dispatchMessage(Handler.java:102)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.os.Looper.loop(Looper.java:148)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.app.ActivityThread.main(ActivityThread.java:5417)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at java.lang.reflect.Method.invoke(Native Method)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): Caused by: android.content.res.Resources$NotFoundException: File ModernHttpClient.Android from drawable resource ID #0x7f080051: .xml extension required
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2758)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.content.res.Resources.loadColorStateList(Resources.java:2699)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.content.res.Resources.getColor(Resources.java:976)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.content.Context.getColor(Context.java:441)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.support.v4.content.ContextCompatApi23.getColor(ContextCompatApi23.java:32)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.support.v4.content.ContextCompat.getColor(ContextCompat.java:432)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.support.design.widget.TextInputLayout.setErrorEnabled(TextInputLayout.java:628)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at md52383f3bfe5cb92264ccfe16c72588a4e.MainActivity.n_onCreate(Native Method)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at md52383f3bfe5cb92264ccfe16c72588a4e.MainActivity.onCreate(MainActivity.java:30)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.app.Activity.performCreate(Activity.java:6237)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): ... 9 more
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): ", PeerReference: JniObjectReference { Handle: IntPtr { }, Type: Global, IsValid: True }, Handle: IntPtr { }, LocalizedMessage: "Unable to start activity ComponentInfo{com.testco.android.testapp/md52383f3bfe5cb92264ccfe16c72588a4e.MainActivity}: android.content.res.Resources$NotFoundException: File ModernHttpClient.Android from drawable resource ID #0x7f080051: .xml extension required", Message: "Unable to start activity ComponentInfo{com.testco.android.testapp/md52383f3bfe5cb92264ccfe16c72588a4e.MainActivity}: android.content.res.Resources$NotFoundException: File ModernHttpClient.Android from drawable resource ID #0x7f080051: .xml extension required", Data: [], InnerException: RuntimeException { JniPeerMembers: XAPeerMembers { ManagedPeerType: Java.Lang.RuntimeException, JniPeerTypeName: "java/lang/RuntimeException", JniPeerType: JniType { PeerReference: JniObjectReference { Handle: IntPtr { }, Type: Global, IsValid: True } }, InstanceMethods: JniInstanceMethods { }, InstanceFields: JniInstanceFields { }, StaticMethods: JniStaticMethods { }, StaticFields: JniStaticFields { } }, StackTrace: " at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <4baa936e3c434e3ba112aa790597bb76>:0
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <fc
04-30 11:33:39.799: E/TestApp.Mobile.Droid.MainActivity(3177): --------- beginning of crash
04-30 11:33:39.800: E/AndroidRuntime(3177): FATAL EXCEPTION: main
04-30 11:33:39.800: E/AndroidRuntime(3177): Process: com.testco.android.testapp, PID: 3177
04-30 11:33:39.800: E/AndroidRuntime(3177): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.testco.android.testapp/md52383f3bfe5cb92264ccfe16c72588a4e.MainActivity}: android.content.res.Resources$NotFoundException: File ModernHttpClient.Android from drawable resource ID #0x7f080051: .xml extension required
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.app.ActivityThread.-wrap11(ActivityThread.java)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.os.Handler.dispatchMessage(Handler.java:102)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.os.Looper.loop(Looper.java:148)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.app.ActivityThread.main(ActivityThread.java:5417)
04-30 11:33:39.800: E/AndroidRuntime(3177): at java.lang.reflect.Method.invoke(Native Method)
04-30 11:33:39.800: E/AndroidRuntime(3177): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
04-30 11:33:39.800: E/AndroidRuntime(3177): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-30 11:33:39.800: E/AndroidRuntime(3177): Caused by: android.content.res.Resources$NotFoundException: File ModernHttpClient.Android from drawable resource ID #0x7f080051: .xml extension required
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.content.res.Resources.loadColorStateListForCookie(Resources.java:2758)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.content.res.Resources.loadColorStateList(Resources.java:2699)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.content.res.Resources.getColor(Resources.java:976)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.content.Context.getColor(Context.java:441)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.support.v4.content.ContextCompatApi23.getColor(ContextCompatApi23.java:32)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.support.v4.content.ContextCompat.getColor(ContextCompat.java:432)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.support.design.widget.TextInputLayout.setErrorEnabled(TextInputLayout.java:628)
04-30 11:33:39.800: E/AndroidRuntime(3177): at md52383f3bfe5cb92264ccfe16c72588a4e.MainActivity.n_onCreate(Native Method)
04-30 11:33:39.800: E/AndroidRuntime(3177): at md52383f3bfe5cb92264ccfe16c72588a4e.MainActivity.onCreate(MainActivity.java:30)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.app.Activity.performCreate(Activity.java:6237)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
04-30 11:33:39.800: E/AndroidRuntime(3177): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
04-30 11:33:39.800: E/AndroidRuntime(3177): ... 9 more

ListView Grouping

$
0
0

hi,listview grouping help me ..
my function ;
`
public async Task getVoyagesData()
{
voyagesList.Clear();
try
{
var uri = new Uri(url);
HttpClient myClient = new HttpClient();
var response = await myClient.GetAsync(uri);
var content = await response.Content.ReadAsStringAsync();
JObject results = JObject.Parse(content);
var results2 = results["data"];
if (response.IsSuccessStatusCode)
{

                foreach (var i in results2)
                {
                        VoyagesMdl voyDay = new VoyagesMdl();
                        VoyagesMdl voyNight = new VoyagesMdl();


                        string clock;
                        clock = i["time"].Value<string>().Substring(11);
                        int clockker = Convert.ToInt32(clock.Substring(0, 2));

                    if (!(clockker > 18 || clockker < 6))
                    {
                        voyDay.opactiy = "1";
                        voyDay.rectangle_price = "rectangle.png";
                        voyDay.rectangle2_date = "rectangle2.png";
                        voyDay.resim = "day.png";
                        voyDay.textcolor = "Black";

                        if (i["prop_ekran"].Value<bool>())
                            voyDay.prop_ekran_img = "ekrantv_day.png";
                        else
                            voyDay.prop_ekran_img = "null";

                        if (i["prop_ekranmuzik"].Value<bool>())
                            voyDay.prop_ekran_img = "ekranmuzik_day.png";
                        else
                            voyDay.prop_ekran_img = "null";


                        if (i["prop_k21"].Value<bool>())
                            voyDay.koltuktipi = "2+2";
                        else
                            voyDay.koltuktipi = "2+1";

                        voyDay.clock = clock;
                        voyDay.id = i["id"].Value<int>();
                        voyDay.name = i["name"].Value<string>();
                        voyDay.time = i["time"].Value<string>();
                        voyDay.time_description = i["time_description"].Value<string>();
                        voyDay.extra = i["extra"].Value<bool>();
                        voyDay.vehicle_type = i["vehicle_type"].Value<string>();
                        voyDay.list_price = i["list_price"].Value<decimal>();
                        voyDay.price = i["price"].Value<decimal>() + " ₺";
                        voyDay.prop_ekran10 = i["prop_ekran10"].Value<bool>();
                        voyDay.prop_ekrantv = i["prop_ekrantv"].Value<bool>();
                        voyDay.prop_ekranmuzik = i["prop_ekranmuzik"].Value<bool>();
                        voyDay.prop_ekranfm = i["prop_ekranfm"].Value<bool>();
                        voyDay.prop_geneltv = i["prop_geneltv"].Value<bool>();
                        voyDay.prop_cep = i["prop_cep"].Value<bool>();
                        voyDay.prop_usbsarj = i["prop_usbsarj"].Value<bool>();
                        voyDay.prop_v220 = i["prop_v220"].Value<bool>();
                        voyDay.prop_internet = i["prop_internet"].Value<bool>();
                        voyDay.prop_futbol = i["prop_futbol"].Value<bool>();
                        voyDay.prop_wc = i["prop_wc"].Value<bool>();
                        voyDay.prop_kulaklik = i["prop_kulaklik"].Value<bool>();
                        voyDay.prop_express = i["prop_express"].Value<bool>();

                        voyagesListDay.Add(voyDay);
                    }
                    else
                    {
                        voyNight.opactiy = "1";
                        voyNight.rectangle_price = "rectangle_night.png";
                        voyNight.rectangle2_date = "rectangle2_night.png";
                        voyNight.resim = "night.png";
                        voyNight.textcolor = "White";

                        if (i["prop_ekran"].Value<bool>())
                            voyNight.prop_ekran_img = "ekrantv.png";
                        else
                            voyNight.prop_ekran_img = "null";

                        if (i["prop_ekranmuzik"].Value<bool>())
                            voyNight.prop_ekran_img = "ekranmuzik.png";
                        else
                            voyNight.prop_ekran_img = "null";


                        if (i["prop_k21"].Value<bool>())
                            voyNight.koltuktipi = "2+2";
                        else
                            voyNight.koltuktipi = "2+1";

                        voyNight.clock = clock;
                        voyNight.id = i["id"].Value<int>();
                        voyNight.name = i["name"].Value<string>();
                        voyNight.time = i["time"].Value<string>();
                        voyNight.time_description = i["time_description"].Value<string>();
                        voyNight.extra = i["extra"].Value<bool>();
                        voyNight.vehicle_type = i["vehicle_type"].Value<string>();
                        voyNight.list_price = i["list_price"].Value<decimal>();
                        voyNight.price = i["price"].Value<decimal>() + " ₺";
                        voyNight.prop_ekran10 = i["prop_ekran10"].Value<bool>();
                        voyNight.prop_ekrantv = i["prop_ekrantv"].Value<bool>();
                        voyNight.prop_ekranmuzik = i["prop_ekranmuzik"].Value<bool>();
                        voyNight.prop_ekranfm = i["prop_ekranfm"].Value<bool>();
                        voyNight.prop_geneltv = i["prop_geneltv"].Value<bool>();
                        voyNight.prop_cep = i["prop_cep"].Value<bool>();
                        voyNight.prop_usbsarj = i["prop_usbsarj"].Value<bool>();
                        voyNight.prop_v220 = i["prop_v220"].Value<bool>();
                        voyNight.prop_internet = i["prop_internet"].Value<bool>();
                        voyNight.prop_futbol = i["prop_futbol"].Value<bool>();
                        voyNight.prop_wc = i["prop_wc"].Value<bool>();
                        voyNight.prop_kulaklik = i["prop_kulaklik"].Value<bool>();
                        voyNight.prop_express = i["prop_express"].Value<bool>();

                        voyagesListNight.Add(voyNight);
                    }
                }





                var list = new List<VoyagesListGroup>()
                {
                    voyagesListDay,
                    voyagesListNight,
                };


                voyagesListDay.Heading = "test";
                voyagesListNight.Heading = "test";


                ListOfGroupVoyages = list;

                voyagesListview.ItemsSource = null;
                voyagesListview.ItemsSource = ListOfGroupVoyages;



                animationView.IsPlaying = false;
                animationView.Pause();
                animationView.Loop = false;
                animationView.IsEnabled = false;
                animationView.IsVisible = false;
            }
        }
        catch (Exception ex)
        {
            Debug.WriteLine(ex);
        }
    }

my xaml listview :

    <ListView x:Name="voyagesListview"  IsGroupingEnabled="True" 
              HasUnevenRows="True" Grid.Row="4" >

        <ListView.GroupHeaderTemplate>
            <DataTemplate>
                <ViewCell>

                </ViewCell>
            </DataTemplate>
        </ListView.GroupHeaderTemplate>

        <ListView.ItemTemplate>
            <DataTemplate>
                <ViewCell>
                    <Grid  RowSpacing="0" Opacity="1">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="35"/>
                            <RowDefinition Height="35"/>
                            <RowDefinition Height="35"/>
                            <RowDefinition Height="1"/>
                        </Grid.RowDefinitions>

                        <Image Source="{Binding resim}" 
                               x:Name="daySource"   
                               Grid.RowSpan="3" Aspect="AspectFill">
                        </Image>

                        <Grid Grid.Row="0" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="50"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="70"/>
                            </Grid.ColumnDefinitions>


                            <Image Source="path_black.png"  Grid.Column="0" Margin="10"/>
                            <Label 

                                Text="{Binding koltuktipi}"
                                TextColor="{Binding textcolor}"
                                Grid.Column="1" 
                                VerticalTextAlignment="Center" HorizontalTextAlignment="Start"
                                FontSize="13">
                                <Label.FontFamily>
                                    <OnPlatform x:TypeArguments="x:String">
                                        <On Platform="Android" Value="openlight.ttf#openlight" />
                                        <On Platform="iOS" Value="openlight.ttf#openlight" />
                                    </OnPlatform>
                                </Label.FontFamily>
                            </Label>

                            <Image x:Name="img_path"  Source="path_white.png"   Grid.Column="0" Margin="10"/>
                            <Label 
                                Text="{Binding vehicle_type}"
                                TextColor="{Binding textcolor}"
                                Grid.Column="2" 
                                VerticalOptions="Center" HorizontalOptions="Center"
                                HorizontalTextAlignment="Center"
                                VerticalTextAlignment="Center">
                                <Label.FontFamily>
                                    <OnPlatform x:TypeArguments="x:String">
                                        <On Platform="Android" Value="open.ttf#open" />
                                        <On Platform="iOS" Value="open.ttf#open" />
                                    </OnPlatform>
                                </Label.FontFamily>
                            </Label>
                            <Image Source="{Binding rectangle_price}" Grid.Column="3" Aspect="Fill"/>
                            <Label 
                                Text="{Binding price}"
                                TextColor="White"
                                Grid.Column="3" 
                                VerticalOptions="Center" HorizontalOptions="Center"
                                HorizontalTextAlignment="Center"
                                VerticalTextAlignment="Center">
                                <Label.FontFamily>
                                    <OnPlatform x:TypeArguments="x:String">
                                        <On Platform="Android" Value="constantia.ttf#constantia" />
                                        <On Platform="iOS" Value="constantia.ttf#constantia" />
                                    </OnPlatform>
                                </Label.FontFamily>
                            </Label>
                        </Grid>

                        <Grid Grid.Row="1" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Label 
                                VerticalOptions="Center"
                                HorizontalOptions="Center"
                                VerticalTextAlignment="Center"
                                HorizontalTextAlignment="Center"
                                Text="{Binding name}"
                                Grid.Column="0"
                                TextColor="{Binding textcolor}">
                                <Label.FontFamily>
                                    <OnPlatform x:TypeArguments="x:String">
                                        <On Platform="Android" Value="openbold.ttf#openbold" />
                                        <On Platform="iOS" Value="openbold.ttf#openbold" />
                                    </OnPlatform>
                                </Label.FontFamily>
                            </Label>
                        </Grid>

                        <Grid Grid.Row="2" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="70"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="70"/>
                            </Grid.ColumnDefinitions>
                            <Image  Source="{Binding rectangle2_date}"  Grid.Column="0"  Aspect="Fill" />
                            <Label 
                             x:Name="otobus_saat"
                            Text="{Binding clock}"
                            TextColor="White"
                            FontSize="20"
                            Grid.Column="0"
                            VerticalTextAlignment="Center" HorizontalTextAlignment="Center">
                                <Label.FontFamily>
                                    <OnPlatform x:TypeArguments="x:String">
                                        <On Platform="Android" Value="constantia.ttf#constantia" />
                                        <On Platform="iOS" Value="constantia.ttf#constantia" />
                                    </OnPlatform>
                                </Label.FontFamily>
                            </Label>


                            <Grid Grid.Column="1" Grid.ColumnSpan="2" VerticalOptions="Center" HorizontalOptions="Center">

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Image Source="{Binding prop_ekran_img}" Grid.Column="0" />
                                <Image Source="{Binding prop_ekranmuzik_img}" Grid.Column="1" />
                            </Grid>



                            <Grid Grid.Column="3">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="20" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Image Source="detay.png" Grid.Column="0" />
                                <Label Text="Detaylı Bilgi"
                                       TextColor="{Binding textcolor}"
                                       Grid.Column="1" FontSize="9" VerticalTextAlignment="Center" HorizontalTextAlignment="Start"/>
                            </Grid>
                        </Grid>


                    </Grid>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>


    </ListView>

`

VoyagesListGroup class ;

public class VoyagesListGroup : List<VoyagesMdl> { public string Heading { get; set; } public List<VoyagesMdl> ListOfGroupVoyages => this; }

my VoyagesMdl class ;

` public class VoyagesMdl
{
public string opactiy { get; set; }
public string resim { get; set; }
public string textcolor { get; set; }
public string otobus_tipi { get; set; } //otobus_tipi
public string rectangle_price { get; set; } // paranın olduğu yerin background resmi // gece ,, gündüze göre değişyior
public string rectangle2_date { get; set; } //background
public string clock { get; set; }
public string koltuktipi { get; set; }

    // küçük logolar
    public string prop_ekran_img { get; set; }
    public string prop_ekranmuzik_img { get; set; }



    public int id { get; set; }
    public string name { get; set; }
    public string time { get; set; }
    public string time_description { get; set; }
    public bool extra { get; set; }
    public string vehicle_type { get; set; }
    public decimal list_price { get; set; }
    public string price { get; set; }
    public bool prop_k21 { get; set; }
    public bool prop_ekran { get; set; }
    public bool prop_ekran10 { get; set; }
    public bool prop_ekrantv { get; set; }
    public bool prop_ekranmuzik { get; set; }
    public bool prop_ekranfm { get; set; }
    public bool prop_geneltv { get; set; }
    public bool prop_cep { get; set; }
    public bool prop_usbsarj { get; set; }
    public bool prop_v220 { get; set; }
    public bool prop_internet { get; set; }
    public bool prop_futbol { get; set; }
    public bool prop_wc { get; set; }
    public bool prop_kulaklik { get; set; }
    public bool prop_express { get; set; }

}`

Using declarative style C# instead of XAML - should Xamarin redirect XAML efforts elsewhere?

$
0
0

Introduction

Miguel tweeted:
"I should have never added Xaml and instead invented our own ...", expressing regrets about having to deal with XAML (standardization) problems.

My response was:
"I would applaud dropping XAML altogether. Advancements in C# (declarative syntax) have eliminated any advantages of a separate markup language for years. Why would you want to hand-code an object serialization format? Why waste time on duplicating dev tools for features that c# already offers?"

David expressed an interest to see how I have been creating Xamarin Forms markup in declarative style C#, instead of in XAML, for the past few years. So I write this post to provide a concrete example, and share the reasoning behind my remark (which was deliberately lacking nuance - it is Twitter after all).

Redirecting Xamarin IDE team effort

Why do I spend time on this? In the past years I only experienced advantages from using declarative C# instead of XAML. Given that the core challenge for the Xamarin IDE teams remains to improve the developer productivity, I would love to see some of the effort now being spent on (imo redundant) XAML tooling to be redirected towards reducing IDE bugs and speeding up the dev cycle, i.e. Live Player.

I recently investigated Google's Flutter (build beautiful native apps in record time), which by design has no separate language for markup and which offers hot reload - which is like a Xamarin Live Player without any limitations and a refresh time of 400-600 ms (I checked on devices and emulators). This is what I want from Xamarin!

This is the competition Xamarin is facing today. Some developers are already switching from Xamarin to Flutter because of developer tooling productivity, which apparently can be more important than language or framework or experience. As a Xamarin veteran, I get why they do this. I feel that unless there is a significant team increase, Xamarin needs to focus and redirect existing effort towards developer productivity, meaning less IDE bugs and faster development cycle.

Example
.
Here is an unabridged example of a simple registration code page in a production app I wrote:

Content = new Grid { 
    RowSpacing = 0, 
    RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition {}},
    Children = {
        PageHeader.Create(PageMarginSize, nameof(vm.RegistrationTitle), returnToPreviousViewCommandPropertyName: nameof(vm.CancelEnterRegistrationCodeCommand), centerTitle:true),

        new ScrollView { Content = new Grid {
            RowDefinitions = {
                new RowDefinition { Height = 170 },

                new RowDefinition { Height = 75 },
                new RowDefinition { Height = GridLength.Auto },
                new RowDefinition { Height = GridLength.Auto }
            },
            RowSpacing = 0,

            ColumnDefinitions = {
                new ColumnDefinition { Width = 160 },
                new ColumnDefinition { }
            },

            Children = {
                new Label {
                    Margin = fieldNameMargin, LineBreakMode = LineBreakMode.WordWrap, 
                    HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, 
                }.SetFontSize(WspFontSizes.Size15)
                 .SetColRow(0, 2, 0, 1)
                 .Bind(nameof(vm.RegistrationPrompt)),

                new Label { Text = "Registration code", VerticalOptions = LayoutOptions.End, Margin = fieldNameMargin }.SetFontSize(WspFontSizes.Size13)
                .SetColRow(0, 1, 1, 2),
                new Label { HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.End, Margin = fieldNameMargin }.SetFontSize(WspFontSizes.Size13)
                .SetColRow(1, 2, 1, 2)
                .Bind(nameof(vm.RegistrationCodeValidationMessage)),

                new Entry {
                    Placeholder = "E.g. 123456", HeightRequest = 44, Keyboard = Keyboard.Numeric, 
                    BackgroundColor = WspColors.White.ToColor(), TextColor = WspColors.Gray1.ToColor(), Margin = fieldMargin }.SetFontSize(WspFontSizes.Size15)
                .Bind(nameof(vm.RegistrationCode), BindingMode.TwoWay)
                .Id(AId.RegistrationCodePage_CodeEntry)
                .SetColRow(0, 2, 2, 3),

                new Button {
                    Text = "Verify",
                    Margin = PageMarginSize,
                    HeightRequest = 44,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    TextColor = WspColors.White.ToColor(),
                    BackgroundColor = WspColors.ColorValueAccent.ToColor()
                }.SetFontSize(WspFontSizes.Size13)
                 .Id(AId.RegistrationCodePage_VerifyCodeButton)
                 .Bind(Button.IsVisibleProperty, nameof(vm.CanVerifyRegistrationCode))
                 .Bind(nameof(vm.VerifyRegistrationCodeCommand))
                 .SetColRow(0, 2, 3, 4),
            }
        }}.SetColRow(0, 1)
     }
 };

Nothing advanced is going on here, I use standard C# language features to reuse controls (e.g. PageHeader.Create method ) and to simplify data binding (.Bind extension methods). In my eyes the above reads similar to equivalent XAML.

Which is not very surprising given that XAML is at its heart just an object serialization format in XML. In other words, XAML does what the new keyword in C# does.

Now, C# is designed for humans; while XML is better for tools such as visual designers. As a matter of fact, that was the vision for (WPF) XAML: that human designers could use a tool (Blend) to create a UI that developers could consume. However, I experienced how that vision, even in the best possible time and scenario, failed to deliver (I Built a WPF app for Windows tablet together with a XAML book authoring, leading designer, who was a master in Blend, when that was THE tool. The UI was beautiful and totally unmaintainable). So even if there would come an ultimate visual designer tool for Xamarin Forms, equivalent to the best that Blend ever was, it would still fail for the same reasons. Time to move on, like Flutter?

So, anyone (Xamarin devs and Xamarin team) wants to chime in on either XAML versus C# or redirecting Xamarin IDE efforts?
I'm really curious how Xamarin devs (especially experienced ones) see this.

Thanks!

Trigger a local notification when the application is closed both on android and ios in Xamarin.forms

$
0
0

I wanted to create a application, for triggering the local notification when the application is closed in Xamarin.forms, And when the application is closed i wanted to check from the web api is in active state for checking whether local notification is assigned or not for a particular user from the database end.

How to display .obj or .fbx file in xamarin forms application for android and ios?

$
0
0

How to display .obj or .fbx file in xamarin forms application for android and ios?


Can't change Hierarchical Navigation

$
0
0

Hi,

I'm 100% new to Xamarin.

I've downloaded the sample code from the Xamarin developer website (sorry, can't post link). When I edit that code, I can't make page 1 navigate to page 3. When I replace:

    async void OnNextPageButtonClicked (object sender, EventArgs e)
    {
        await Navigation.PushAsync (new Page2 ());
    }

With

    async void OnNextPageButtonClicked (object sender, EventArgs e)
    {
        await Navigation.PushAsync (new Page3 ());
    }

and I debug, the "Next Page" button on page 1 still links to page 2. I've spent 1 hour trying all sorts of solutions and I'm lost. Can you help?

Thanks and best regards,

Carl Juneau, PhD

BottomNavigationBarXF icon color

$
0
0

Hi,
getting nuts here, trying to do something that I suppose should be pretty simple but however I try I can't get it to work.

I use the BottomNavigationBarXF Package to get a tab bar att the bottom on Android in my forms project it works and all I want to do now is make the backrond of the bar white and my icons black but I cant get it to work. Does someone now how to do this?

Best regards
/magnus

What is this Json error message?

$
0
0

I got following message, Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
I don't know what this means. Whenever I clicked certain button, error occurs with this message. What does this message mean and how can I solve?
Thank you

Reference to type GoogleMap.IOnCameraMoveListener claims it is defined in Xamarin.GooglePlayServices

$
0
0

Hello everbody!

I'm facing an issue related with a reference, as the title shows I'm getting:

Reference to type 'GoogleMap.IOnCameraMoveListener' claims it is defined in 'Xamarin.GooglePlayServices.Maps', but it could not be found C:\Users\App.Xamarin\App.Android\CustomMapRenderer.cs

I been trying to use the live player on a Samsung Galaxy S8+ Android API 27 with no success.

`
using Android.Gms.Maps.Model;
using App.Android;
using App.Portable.Vista.ControlesUsuario.Mapas;
using System.Collections.Generic;
using Xamarin.Forms;
using Xamarin.Forms.Maps;
using Xamarin.Forms.Maps.Android;

[assembly: ExportRenderer(typeof(MapaGoogle), typeof(CustomMapRenderer))]
namespace App.Android
{
public class CustomMapRenderer : MapRenderer
{
List routeCoordinates;
bool isDrawn;

    protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Map> e)
    {
        base.OnElementChanged(e);

        if (e.OldElement != null)
        {
            // Unsubscribe
        }

        if (e.NewElement != null)
        {
            var formsMap = (MapaGoogle)e.NewElement;
            routeCoordinates = formsMap.RouteCoordinates;
            Control.GetMapAsync(this);
        }
    }

    protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {
        base.OnElementPropertyChanged(sender, e);

        if (e.PropertyName.Equals("VisibleRegion") && !isDrawn)
        {
            var polylineOptions = new PolylineOptions();
            polylineOptions.InvokeColor(0x66FF0000);

            foreach (var position in routeCoordinates)
            {
                polylineOptions.Add(new LatLng(position.Latitude, position.Longitude));
            }

            NativeMap.AddPolyline(polylineOptions);
            isDrawn = true;
        }
    }
}

}`

I spent 2 days already trying to figure out what's going on but it is quite hard to find a solution as the error is too specific if I am not mistaken.

Also, I do not know if it is related with the NuGet packages that require updates GooglePlayServices, Forms and so on. However, whenever I update them the references are missed in the whole solution.

Any help will be highly appreciated !

Cheers,

Eric R.

MR.Gestures handles ALL touch gestures

$
0
0

With MR.Gestures you can handle the Tapping, Tapped, DoupleTapped, LongPressing, LongPressed, Panning, Panned, Swiped, Pinching, Pinched, Rotating and Rotated gestures on all layouts, cells, views and on the ContentPage.

The code can be as easy as

    var box1 = new MR.Gestures.BoxView { Color = Color.Red };
    box1.LongPressed += (s, e) => { Console.WriteLine("Code: Red LongPressed"); };

Or in XAML

<br /><mr:ContentView xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:mr="clr-namespace:MR.Gestures;assembly=MR.Gestures"
             x:Class="GestureSample.Views.ContentViewXaml"

             Padding="50"

             TappingCommand="{Binding TappingCommand}"
             TappedCommand="{Binding TappedCommand}"
             DoubleTappedCommand="{Binding DoubleTappedCommand}"
             LongPressingCommand="{Binding LongPressingCommand}"
             LongPressedCommand="{Binding LongPressedCommand}"
             PanningCommand="{Binding PanningCommand}"
             PannedCommand="{Binding PannedCommand}"
             SwipedCommand="{Binding SwipedCommand}"
             PinchingCommand="{Binding PinchingCommand}"
             PinchedCommand="{Binding PinchedCommand}"
             RotatingCommand="{Binding RotatingCommand}"
             RotatedCommand="{Binding RotatedCommand}"
             >

MR.Gestures is available via NuGet. More info on http://www.mrgestures.com/.

There is also a sample app available to download from https://github.com/MichaelRumpler/GestureSample. The GestureSample demonstrates how to use all the gestures with all Xamarin.Forms elements.

Xamarin Auth Account Store

$
0
0

I had been using Xamarin.Auth to save the password locally. After upgrading Xamarin.Auth 1.6.0.2 I can see that AccountStore.Create() method is now obsolete. It suggests to change the signature to AccountStore.Create(Android.Content.Context,String). as the previous method had security concerns.
In my shared project , I changed the definition to AccountStore.Create(Constants.AccountStorePassword), but it gives build error.
Saying "No Overload Method for 'Create' takes one argument".
Can anyone please suggest me what changes do I have to make?
or Do I have to implement the methods natively?

sporadic error when using listview

$
0
0

Hi Experts,

Can anyone tell me why I occasionally get this error?

Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (20) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).

Thanks in advance

percy


Popup keyboard hides parts of the UI rather than resizing

$
0
0

I would like to create a screen that has a behavior similar to common chat apps e.g. Hangouts where there's a scrollable section of the page and an Entry with a Button underneath that updates the scrollable section.

I currently have this implemented with a Grid that has a * row (with the scroller) and an Auto row (with the Entry).

On iOS, when I tap the Entry, the keyboard popping up hides the lower half of the screen.

On Android, when I tap the Entry, the keyboard slides up, but the UI slides up as well, getting rid of the top half of the UI.

I get that, yeah, this has been a bug for a while, it's not likely to be fixed any time soon, and so on. Is there a different way to approach this than having a Grid lay out the sections of the page that will work for this use case?

How can i set the focus ( and display the keyboard ) on Entry control.

$
0
0

Hi,

How can i set the focus ( and display the keyboard ) on Entry control in Xamarin forms.

Change the ListView's item template depending a condition on Model

$
0
0

ListView list = new ListView { Style = Styles.DefaultList };

listView.SetBinding (ItemsView.ItemsSourceProperty, "MenuItems");
listView.SetBinding (ItemsView.ItemTemplateProperty, "MenuItems", converter: new ItemSourceToDataConverter( ));

public class SubMenuPadding : IValueConverter
{
    public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if(((ObservableCollection<MenuItem>)value).Where (item => item.changeTemplate == true ))
            return new DataTemplate (typeof(SecondTemplate));

        return new DataTemplate (typeof(FirstTemplate));
    }

    public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        return value;
    }
}

Somethind like this.. But it don't work.
Depending a property state on model, I change the DataModel.

Animating Height Of box view

$
0
0

This is my first foray into Animation for my Forms App. I have seen loads of examples for scaling box views, but thee all seem to scale both heigh and width. I want to scale just the height with animation>

I have tried :

                        bar.Animate("HeightRequest", animation:new  Animation( callback:(double d) => { bar.HeightRequest = d; }, start:0, end:currentBarHeight, easing:Easing.SpringIn), length: 1000);

but this seems to do nothing. Are there any examples out there of scaling just the height of a box view??

Thanks Ash..

Using {Binding .} with value converters

$
0
0

Hi,
I am writing an application using a ListView:

<ListView ItemsSource="{Binding Places}">
        <ListView.ItemTemplate>
          <DataTemplate>
            <ViewCell>
              <Grid>
                <Grid.RowDefinitions>
                  <RowDefinition Height="Auto"/>
                  <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*"/>
                  <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <Label TextColor="White" Text="{Binding Name}" Grid.ColumnSpan="2" FontSize="20" />

                <Label TextColor="White" Text="{Binding Path=. , Converter={StaticResource todayConverter}}" Grid.Row="1" />
                <Label TextColor="White" Text="{Binding Path=. , Converter={StaticResource distanceConverter}}" Grid.Row="1" XAlign="End" Grid.Column="1"/>
              </Grid>
            </ViewCell>
          </DataTemplate>
        </ListView.ItemTemplate>
      </ListView>

I need to pass the whole BindingContext object to my converters but in the converters code is value object set to null:

    class DistanceConverter : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                //value is set to null
                if (value == null) Debug.WriteLine("value is null");

                PizzaPlace i = value as PizzaPlace;

                if (i.DistanceTo < 500)
                {
                    return String.Format("{0} (cca {1:0} m)", i.City, i.DistanceTo);
                }
                return String.Format("{0} (cca {1:0.0} km)", i.City, i.DistanceTo / 1000);
            }

            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }

How can I pass whole BindingContext objects to value converters?

Viewing all 91519 articles
Browse latest View live


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