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

MVVM Listview doesn't update view.

$
0
0

Hi! Thanks for reading this.
I'm try to use MVVM for change some values over listview's items. I update Model but no changes on View.

This is my Listview definition :

My code behind :

void Handle_ItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
{
if (OldItem != null)
OldItem.IsSelected = false;

        OldItem = ((Provider)e.SelectedItem);
    }

This is used for going back IsSelected property when item is not selected anymore.

My view model:

public class AllProvidersViewModel : ContentPage, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

    ObservableCollection<Group> _proveedores = new ObservableCollection<Group>();
    public ObservableCollection<Group> Proveedores
    {
        get { return _proveedores; }
    }


    private Provider _selItem;

    public Provider SelItem
    {
        get { return _selItem; }
        set
        {
            if (value != null)
            {
                _selItem = value;
                _selItem.IsSelected = true;
                _selItem.Level = 1;   //Only for test!
                _selItem.RazonSocial = "I've changed!";  // It never changes on view. 
                OnPropertyChanged("SelItem");

            }

        }
    }

protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

}
}

Model:

public class Group : ObservableCollection
{

    public string Initial { get; set; }

    public Group(string initial)
    {
        Initial = initial;
    }
}

public class Provider {

public bool IsSelected {get; set;}

public Level {get; set;}
public RazonSocial {get; set}
}

Some code was removed intentionally-

So, There is not problem for populate the listview. All data is in it.
When I select an item, set method on SelItem is called. It change IsSelected, Level and RazonSocial in the model, but view doesn't change.
If I select another item, and then select previous item again, _selItem keep changes, but the view never show that changes.

Any Clue?

Thanks!

Gaston


I can't deploy iOS app to simulator or my iPhone

$
0
0

I built an iOS app successfully. When I try to deploy it to debug, I get the following message:

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Deploy: 0 succeeded, 0 failed, 0 skipped ==========

Then nothing happens; the app is not deployed to the device.

however, it does say "[Inspector] Error preparing project for inspection" in the output, I dont know if this is preventing the launch/deployment ... :(

In Xamarin forms project uwp app does not debug throws error: The application cannot be started

$
0
0

I am building xamarin forms app in that i am not able to debug the uwp app it just throws below error while starting to debug uwp app

Activation for XXXXX_q60vbcv8e4n0m!App failed. Error code: The application cannot be started. Try reinstalling the application to fix the problem.. Activation phase: Deployment,

what is the cause of the error please help to fix it ?

Xamarin.Forms Android Performance

$
0
0

Hello,

I have a Xamarin.Forms project for iOS and Android. For Android, I have implemented a splashscreen based on the famous technic: https://bit.ly/2JQexhB. It works pretty well.
But after showing the splashscreen, the main page always appears by showing a blank white screen first, then the different views appears after around one second as if it has difficulty to render the XAML... However, my XAML code structure is not very complicated.
What can be the problem?

ListView to Infopage

$
0
0

Hi xamarin forum
is it possible to tap an Item in a listView then upon tapping on an item it will go to another page which contains more Details about that item below is my XAML and codebehind for listView

In this code I was able to make use of searchbar to filter what I want to dial or make a call.. but what I want is to add something like 'more info' where I can tap that more info then it will display another page containing more information about the item I tapped/selected so for more clarification if I tapped on 'more info' on Rob's row it will display Rob's Email address Contact numbers Address etc is this possible on my code?

XAML

`<StackLayout>
            <SearchBar HeightRequest="50" TextChanged="SearchBar_textChanged"></SearchBar>
            <ListView  x:Name="Contacts">
                <ListView.Header>
                    <Grid ColumnSpacing="0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Label Text="Name" Grid.Row="0" Grid.Column="0" HorizontalOptions="CenterAndExpand" />
                        <Label Text="Company" Grid.Row="0" Grid.Column="1" HorizontalOptions="CenterAndExpand"/>
                        <Label Text="Phone" Grid.Row="0" Grid.Column="2" HorizontalOptions="CenterAndExpand" />
                    </Grid>
                </ListView.Header>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Orientation="Vertical">
                                <StackLayout Orientation="Horizontal">
                                    <Label Text="{Binding CustomerName}" Margin="40,10,20,0"/>
                                    <Label Text="{Binding Address}" Margin="40,10,20,0"/>
                                    <Label Text="{Binding Phone}" Margin="15,10,20,0"/>
                                </StackLayout>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>`

And This is my code behind

            using System;
            using System.Collections.Generic;
            using System.Data;
            using System.Data.SqlClient;
            using System.Linq;
            using Xamarin.Forms;

            public partial class Contactpage : ContentPage
            {
              public List<User> tempdata;

              public Contactpage()
              {
                        InitializeComponent ();
                        BindCustomerRecords();
                        Contacts.ItemsSource = tempdata; 
              }

              private void BindCustomerRecords()
              {
                        tempdata = new List<User>
                        {
                            new User(){CustomerName = "Kyle", Address= "Abc St. 123456uj", Phone="111111" },
                            new User(){CustomerName = "Rob", Address= "Abdw St. f30054", Phone="12345675" },
                            new User(){CustomerName = "Martin", Address= "Aqw St. 12345q2j", Phone="556795" },
                            new User(){CustomerName = "Mike", Address= "Abc St. 123456uj", Phone="235465" }
                        };
              }

                    private void SearchBar_textChanged(object sender, TextChangedEventArgs e)
                    {
                        Contacts.BeginRefresh();

                        if (string.IsNullOrEmpty(e.NewTextValue))
                        {
                            Contacts.ItemsSource = tempdata;
                        }
                        else
                        {
                            Contacts.ItemsSource = tempdata.Where(x => x.CustomerName.StartsWith(e.NewTextValue));
                        }

                        Contacts.EndRefresh();
                    }
            }

    void SelectedNumber(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
    {

        var SelectedContact = ((ListView)sender).SelectedItem as User;
        if (SelectedContact == null)
            return;

        var phoneDial = Plugin.Messaging.CrossMessaging.Current.PhoneDialer;
        if (phoneDial.CanMakePhoneCall)
            phoneDial.MakePhoneCall(SelectedContact.Phone);

    }

Image Will Not Aspect Fit/Fill While Inside ScrollView

$
0
0

I'm having a real hard time trying to figure out this problem and I'm hoping someone can help.

I have a Grid with a few Rows defined. Within one of those rows is a single ScrollView. That ScrollView has a Grid with a single Image inside that's used as a sort of BackGround Image for one section. No matter what I do I cannot get the Image to Fill, AspectFill or AspectFit inside the Parent Grid (I have also tried a StackView to no avail). If I eliminate the ScrollView and pull the Grid and Image out the Image will Fit or Fill just fine.

Here is a stripped down example of what I'm doing:

<Grid ColumnSpacing="0" RowSpacing="0">
    <Grid.RowDefinitions>
        <RowDefinition Height="48"/>
        <RowDefinition Height="4"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid Grid.Row="0"> ... </Grid>
    <Grid Grid.Row="1"> ... </Grid>
    <ScrollView Orientation="Vertical" HorizontalOptions="FillAndExpand" 
        VerticalOptions="FillAndExpand" Grid.Row="2">
            <Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
            <!-- THIS IMAGE WILL NOT FILL! -->
                <Image Source="{local:EmbeddedImage  Project.Mobile.Images.fieldBackground.png}" Aspect="Fill" />
            </Grid>
    ... More Code ...
    </ScrollView>
</Grid>

No matter what I do the Image will not Fill the Grid Parent. If I remove the ScrollView it works just fine like this but I cannot do this without a ScrollView because I have more content directly below that cannot fit on the screen.

<Grid ColumnSpacing="0" RowSpacing="0">
    <Grid.RowDefinitions>
        <RowDefinition Height="48"/>
        <RowDefinition Height="4"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid Grid.Row="0"> ... </Grid>
    <Grid Grid.Row="1"> ... </Grid>
    <Grid Grid.Row="2" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >
    <!-- THIS IMAGE FILLS FINE! -->
        <Image Source="{local:EmbeddedImage  Project.Mobile.Images.fieldBackground.png}" Aspect="Fill" />
    </Grid>
</Grid>

As a workaround I attempted to not aspect fit/fill the image but to anchor it at the top of the Grid and let it fill horizontally. But I cannot get the image to fit any other way inside the Grid besides centered vertically no matter what I try. If I make the Grid the exact height of the image it almost works but it looks different between iOS and Android. This seems like such a simple thing? What am I missing? I've wasted hours on this so far.

Thanks,
Any help is appreciated!

Extremely simple image upload keeps timing out

$
0
0

Hello, I've spent out try to figure out why my image upload keeps timing out. Everything has worked before but i seem to be struggling on something trival.

here is my post to my web api

byte[] ImageUploadBase64;

    private async void Button_Clicked(object sender, EventArgs e)
    {
        await CrossMedia.Current.Initialize();

        if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
        {
            await DisplayAlert("No Camera", ":( No camera available.", "OK");
            return;
        }

        var file = await CrossMedia.Current.PickPhotoAsync();
        if (file == null)
            return;


        using (var memoryStream = new MemoryStream())
        {
            file.GetStream().CopyTo(memoryStream);
            var myfile = memoryStream.ToArray();
            ImageUploadBase64 = myfile;
        }

        var check = await UploadTheImage();
    }


    public async Task<HttpResponseMessage> UploadTheImage()
    {
        Stream stream = new MemoryStream(ImageUploadBase64);
        var FixedFileName = DateTime.Now.Millisecond + "PhotoDocument" + "1234" + ".jpg";

        StreamContent scontent = new StreamContent(stream);
        scontent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
        {
            FileName = FixedFileName,
            Name = "image"
        };

        scontent.Headers.ContentType = new MediaTypeHeaderValue("image/jpg");
        var client = new HttpClient(new NativeMessageHandler());
        var multi = new MultipartFormDataContent();

        multi.Add(scontent);

        client.BaseAddress = new Uri("myUrl");

        HttpResponseMessage result = await client.PostAsync("api/UploadImage/", multi).ConfigureAwait(false);

       // var ResultResponse = await result.Content.ReadAsStringAsync();

        return result;
    }

and my endpoint which im just trying to save the image to disk

[HttpPost]
[Route("api/UploadImage")]
public Task ImageUpload()
{
if (!Request.Content.IsMimeMultipartContent())
{

            return null;

        }
        else
        {

            string root = HttpContext.Current.Server.MapPath("~/Files/Photos");
            var provider = new CustomMultipartFormDataStreamProvider(root);

            var task = Request.Content.ReadAsMultipartAsync(provider).ContinueWith<HttpResponseMessage>(t =>
            {
                if (t.IsFaulted || t.IsCanceled)
                {
                    Request.CreateErrorResponse(HttpStatusCode.InternalServerError, t.Exception);
                }
                foreach (MultipartFileData uploadedFile in provider.FileData)
                {

                    string path = provider.FileData[0].LocalFileName;
                    int pos = path.LastIndexOf("\\") + 1;
                    string GeneratedFileName = path.Substring(pos, path.Length - pos);

                   // var UpdateGoal = db.UserGoals.SingleOrDefault(x => x.UserID == GetUser.ID && x.UserGuid == UserGuid && x.ID == NewGoalID);

                    using (Image image = Image.FromFile(root + "\\" + GeneratedFileName))
                    {
                        using (MemoryStream m = new MemoryStream())
                        {
                            image.Save(m, image.RawFormat);
                            byte[] imageBytes = m.ToArray();

                                // Convert byte[] to Base64 String
                              string base64String = Convert.ToBase64String(imageBytes);


                            //UpdateGoal.GoalImageFile = base64String;
                            //UpdateGoal.GoalImageUrl = "url" + GeneratedFileName;
                            //UpdateGoal.GoalTypeID = 2;

                            //db.SaveChanges();


                        }

                    }

                }
                return Request.CreateResponse(HttpStatusCode.OK);

            });
            //task.Wait();
            return task;

        }
    }

the task just continues to cancel after a minute, ive also tried extending the HttpClient Timeout which has no affect. I've tried with smalled sized images, and checking the image that i select is a max of 500k so its not that the image is too large.

any ideas??

need help, Xamarin PCL uploading Images

$
0
0

Hey Everyone,

just a weird but pretty annoying problem. I am going to upload images to Web server using Httpclient.

If I am using "http://10.0.0.62" as BaseAddress, which is on my local network environment, it is OK.
If I am using "http://xxx.xxx.com.au", which is outside my local network environment, then iOS is working, but on an Android device, it always gets an error " the object was used after being disposed".

I think web server should be OK, as it accepts the images from iOS device.
The code should be fine as well, as iOS can upload images without any problem.

So, what should be the problems? It annoys me for the whole day, but I can't find out anything that could cause the problem.

Please help!

Thanks in advance.

Ting


iOS app crashed while opening and closing the WebView (WKWebView)

$
0
0

I'm developing an iOS application using Xamarin.Forms and it contains WebView in it. Recently my iOS crashing while opening and closing the WebView. It works fine in my iPad (iOS 10.1.1) but crashing in my iPod (iOS 11.3).

Here is my app crash report,

Thread 4 name:  Finalizer
Thread 4 Crashed:
0   WebKit                          0x0000000192dd08e4 

WebKit::WebCookieManagerProxy::processPoolDestroyed+ 1747172 () + 448

1   WebKit                          0x0000000192dd0744 WebKit::WebCookieManagerProxy::processPoolDestroyed+ 1746756 () + 32
2   WebKit                          0x0000000192ee0530 WebKit::WebProcessPool::~WebProcessPool+ 2860336 () + 260
3   WebKit                          0x0000000192fa0cf0 -[WKProcessPool dealloc] + 36
4   WebKit                          0x0000000192c4069c API::PageConfiguration::~PageConfiguration+ 108188 () + 212
5   WebKit                          0x0000000192f88e34 -[WKObject dealloc] + 36
6   WebKit                          0x0000000192e66018 WebKit::WebPageProxy::~WebPageProxy+ 2359320 () + 1932
7   WebKit                          0x0000000192f88e34 -[WKObject dealloc] + 36
8   WebKit                          0x0000000192c3c778 API::FrameInfo::~FrameInfo+ 92024 () + 48
9   WebKit                          0x0000000192f81c68 -[WKFrameInfo dealloc] + 36
10  WebKit                          0x0000000192d830bc API::NavigationAction::~NavigationAction+ 1429692 () + 168
11  WebKit                          0x0000000192f87268 -[WKNavigationAction dealloc] + 36
12  WebKit                          0x0000000192cb82d0 WTF::BlockPtr<void (WKNavigationActionPolicy)> WTF::BlockPtr<void 
WKNavigationActionPolicy)>::fromCallable<WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction(WebKit::WebPageProxy&, WTF::Ref<API::NavigationAction, WTF::DumbPtrTraits<API::NavigationAction> >&&, WTF::Ref<WebKit::WebFramePolicyListenerProxy, WTF::DumbPtrTraits<WebKit::WebFramePolicyListenerProxy> >&&, API::Object*)::$_2>(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction(WebKit::WebPageProxy&, WTF::Ref<API::NavigationAction, WTF::DumbPtrTraits<API::NavigationAction> >&&, WTF::Ref<WebKit::WebFramePolicyListenerProxy, WTF::DumbPtrTraits<WebKit::WebFramePolicyListenerProxy> >&&, API::Object*)::$_2)::'lambda'(void const*)::__invoke+ 598736 (void const*) + 88
13  libsystem_blocks.dylib          0x0000000182c98a5c _Block_release + 152
14  MobileAppiOS    0x00000001018583dc 0x10056c000 + 19842012
15  MobileAppiOS    0x00000001018577c4 0x10056c000 + 19838916
16  MobileAppiOS    0x00000001018cfcbc 0x10056c000 + 20331708
17  libsystem_pthread.dylib         0x0000000182f2d220 _pthread_body + 272
18  libsystem_pthread.dylib         0x0000000182f2d110 _pthread_body + 0
19  libsystem_pthread.dylib         0x0000000182f2bb10 thread_start + 4

Does anyone have idea about this?

How to place a image in the half of a frame using Xamarin forms

$
0
0

Hi, I want to place a image in the half of a frame in my app , i am using xamarin forms to do this ,How can I do this
My Xaml

  <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand" >
                <ListView x:Name="lv_search" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" RowHeight="175" SeparatorColor="White">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                             <AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand" >
          <Frame  BackgroundColor="White" HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand" Margin="20,10,0,0"
                                  HeightRequest="75" AbsoluteLayout.LayoutBounds="0.01,0.9,1,1" AbsoluteLayout.LayoutFlags="All">
                                        <Image Source="img_frm" BackgroundColor="#14559a" AbsoluteLayout.LayoutBounds="0.009,0.9,0.3,0.6" AbsoluteLayout.LayoutFlags="All"  />
                                        <StackLayout Orientation="Horizontal"  HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand">
                                            <AbsoluteLayout  HorizontalOptions="StartAndExpand">
                                            <Image Source="ellipse_1" VerticalOptions="CenterAndExpand" HorizontalOptions="Start" AbsoluteLayout.LayoutFlags="All"
                                                   AbsoluteLayout.LayoutBounds="0.01,0.4,1,1" HeightRequest="100" WidthRequest="100" BackgroundColor="White">

                                            </Image>

                                            <Image Source="{Binding Image}" AbsoluteLayout.LayoutBounds="0.02,0.4,1,1" AbsoluteLayout.LayoutFlags="All"
                                                   HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"  ></Image>
                                            </AbsoluteLayout>

                                            <Label x:Name="lbl_categories" HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand"  Margin="10,0,0,0" 
                                                   TextColor="Black"   Text="{Binding Title}" LineBreakMode="WordWrap"  HorizontalTextAlignment="Start"
                                                   FontSize="Medium" FontAttributes="Bold" AbsoluteLayout.LayoutBounds="0.3,0.3,1,1" AbsoluteLayout.LayoutFlags="All"/>

                                            <Image HorizontalOptions="EndAndExpand" VerticalOptions="Center" Source="arrow"  AbsoluteLayout.LayoutBounds="0.9,0.3,0.3,0.3"
                                                AbsoluteLayout.LayoutFlags="All" />
                                        </StackLayout>
                                    </Frame>

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

But it dosen't develop the design what I want.

Actually I want a design like this

Xcode 9.4.1 seems to break Styles on iOS

$
0
0

I've upgraded from Xcode 9.2 to Xcode 9.4.1, and am finding that Styles defined in my App.xaml no longer work. There is a workaround, which is to create an OnPlatform resource for each setter. However, this is clearly not optimal!

Has anyone else observed this and got a better fix? It should also be logged as a bug I think. There is a similar bug here on GitHub.

It could be an iOS version problem - I'm using different simulators for the two Xcode versions, iOS 11.2 for Xcode 9.2 and iOS 11.4 for Xcode 9.4.1. I haven't tried changing simulators yet.

Code to reproduce it is below.

App.XAML:

<Application.Resources>
        <ResourceDictionary>
            <OnPlatform
                x:Key          ="ButtonBackgroundColor"
                x:TypeArguments="Color"
                Android        ="#ff0180a5"
                iOS            ="#ff0180a5"
                WinPhone       ="#ff0180a5" />
            <OnPlatform
                x:Key          ="ButtonTextColor"
                x:TypeArguments="Color"
                Android        ="White"
                iOS            ="White"
                WinPhone       ="White" />
            <Style
                x:Key     ="StyleButtonWithPlatformSetters"
                TargetType="Button">
                <Setter
                    Property="TextColor"
                    Value   ="{StaticResource ButtonTextColor}" />
                <Setter
                    Property="BackgroundColor"
                    Value   ="{StaticResource ButtonBackgroundColor}" />
            </Style>
            <Style
                x:Key     ="StyleButtonWithPlainSetters"
                TargetType="Button">
                <Setter
                    Property="TextColor"
                    Value   ="White" />
                <Setter
                    Property="BackgroundColor"
                    Value   ="#ff0180a5" />
            </Style>
            <OnPlatform
                x:Key          ="LabelBackgroundColor"
                x:TypeArguments="Color"
                Android        ="Red"
                iOS            ="Red"
                WinPhone       ="Red" />
            <Style
                x:Key     ="StyleLabelWithPlatformSetters"
                TargetType="Label">
                <Setter
                    Property="BackgroundColor"
                    Value   ="{StaticResource LabelBackgroundColor}" />
            </Style>
            <Style
                x:Key     ="StyleLabelWithPlainSetters"
                TargetType="Label">
                <Setter
                    Property="BackgroundColor"
                    Value   ="Red" />
            </Style>
        </ResourceDictionary>
    </Application.Resources>

Page:

    <ContentPage.Content>
        <StackLayout>
            <Label
                HorizontalOptions="Center"
                Style            ="{StaticResource StyleLabelWithPlainSetters}"
                Text             ="Label with plain setters" />
            <Button
                Style       ="{StaticResource StyleButtonWithPlainSetters}"
                Grid.Column ="0"
                Margin      ="20"
                WidthRequest="100"
                Text        ="Show Products"
                Command     ="{Binding ButtonClickCommand}" />
            <Label
                HorizontalOptions="Center"
                Style            ="{StaticResource StyleLabelWithPlatformSetters}"
                Text             ="Label with OnPlatform setters" />
            <Button
                Style       ="{StaticResource StyleButtonWithPlatformSetters}"
                Grid.Column ="0"
                Margin      ="20"
                WidthRequest="100"
                Text        ="Show Products"
                Command     ="{Binding ButtonClickCommand}" />
        </StackLayout>
    </ContentPage.Content>

Result using Xcode 9.4.1 - the top label and button don't use OnPlatform

Result using Xcode 9.2

Icon don't work in BottomTabbedPage in Xamarin Forms 3.1 pre4

$
0
0

My icons worked when I had the tabbed page in the top , now I update them and a put them in the bottom and icon does't show ?

Image gone after GestureRecognizer tap

$
0
0

Hello, so I'm working on an an app that should basically display a picture after you tap it. Like a photo viewing app.

The problem I have is that when I press one of the images in a grid, the app does what it should, but when I return from the tapGestureRecognizer method, the Image preview in the grid is gone. I wanted to post screenshots but apparently I'm too new a user to be allowed something dangerous as that.
I don't know what I'm doing wrong, it's probably something simple but I can't get my head around it.

Thanks for help!

Code (not working in XAML):

using Android.Widget;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace App7
{
    public partial class MainPage : ContentPage
    {
        private Grid firstGrid;
        private bool fullScreenOn = false;
        private ContentView mainContentView;

        public MainPage()
        {
            InitializeComponent();

            // AppHandler test = new AppHandler();

            mainContentView = new ContentView();

            firstGrid = new Grid();

            firstGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
            firstGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
            firstGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

            // making a square 2x3 grid
            firstGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
            firstGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });

            // when clicking an image, this ContentView will fill the entire screen
            ContentView fullscreenView = new ContentView();
            fullscreenView.BackgroundColor = Color.Black;
            fullscreenView.HorizontalOptions = LayoutOptions.FillAndExpand;
            fullscreenView.VerticalOptions = LayoutOptions.FillAndExpand;
            //mainStackLaout.Children.Add(fullscreenView);
            //mainStackLaout.LowerChild(fullscreenView);

            var tapGestureRecognizer = new TapGestureRecognizer();
            tapGestureRecognizer.Tapped += (sender, eventArgs) => {
                fullScreenOn = true;
                Image fullScreenImage = (Image)sender;
                fullscreenView.Content = fullScreenImage;
                mainContentView.Content = fullscreenView;
            };

            Image image1 = new Image() { Source = "aniso.jpg" };
            image1.GestureRecognizers.Add(tapGestureRecognizer);
            Image image2 = new Image() { Source = "band.png" };
            Image image3 = new Image() { Source = "basophil.png" };
            Image image4 = new Image() { Source = "basophil2.png" };
            Image image5 = new Image() { Source = "bild5.jpeg" };
            Image image6 = new Image() { Source = "blast.jpg" };

            firstGrid.Children.Add(image1, 0, 0);
            firstGrid.Children.Add(image2, 1, 0);
            firstGrid.Children.Add(image3, 2, 0);
            firstGrid.Children.Add(image4, 0, 1);
            firstGrid.Children.Add(image5, 1, 1);
            firstGrid.Children.Add(image6, 2, 1);

            mainContentView.Content = firstGrid;

            Content = mainContentView;
        }

        protected override bool OnBackButtonPressed()
        {
            if (fullScreenOn)
            {
                mainContentView.Content = firstGrid;
                fullScreenOn = false;
                return true;
            }
            return base.OnBackButtonPressed();
        }


    }
}

Tabbed Page - Is it possible to Center the Texts/Icons?

$
0
0

Good Day everyone, I really want to center the icons/texts of the items in tabbed page, especially if the screen is in landscape view. Is this possible?

Anyone help me to resolve the sudden crash on my application?

$
0
0

Does anyone help me to resolve the sudden crash on my application?


Render FontAwesome Icon with button

$
0
0

Hi,
I have implemented a bottom navigation bar with four buttons, but I want font awesome icon instead of button and on clicking of icon change the colour of the icon. Is there any way to do that?

Xamarin.Forms WebView while scrolling freezes content (CSS, HTML) progress

$
0
0

Hi guys, it's me again.

I've built a Xamarin.Forms application which contains a full width/height WebView inside. Now, when I start scrolling on that WebView, it freezes my HTML page in the WebView.

For example, any progressbar which is loading on the HTML content of the WebView stops loading / progressing while I'm scrolling. When I finish scrolling, it still doesn't continue the progressbar until I tap inside the WebView on the content, suddenly it starts loading again to the next time I start scrolling.

It's like the WebView freezes while scrolling and waiting for any gestures (tap) to continue the HTML / JS workflow. Or it stops rendering while scrolling, I don't know!

How can I prevent this? I'd like to scroll and let the WebView content work asynchronously farther.

I've tried it only on android devices so far. About iOS there are no informations right now, will test it later. But I guess it's a android problem with their WebView.

I appreciate any answer on this!

Thanks a lot,
Dominik.

How to install android ndk for visual studio 2015 ?

$
0
0

I try installed visual studio 2015 for windows 7, when running demo xamarin was reported "No Android NDK found". I go to "Tools> Options> Xamarin> Android Settings" in this tab I see Android NDK Location -> "No Android NDK found" how do i want to install android ndk for visual studio 2015 ? What can I do ?

TapGesture gives error!!

$
0
0

            <Image Source="Corporational.png" HorizontalOptions="Center">
                <Image.GestureRecognizers>
                    <TapGestureRecognizer Tapped="CorporateRecognizer_Tapped">
                        <TapGestureRecognizer.CommandParameter>
                            <x:Boolean>True</x:Boolean>
                        </TapGestureRecognizer.CommandParameter>
                    </TapGestureRecognizer>

                </Image.GestureRecognizers>

            </Image>
            <Label Text="Kurumsal Müşteri" FontSize="Large" VerticalTextAlignment="Start" HorizontalTextAlignment="Center"  Grid.Row="1"></Label>

        </Grid>

My Method:

 private void CorporateRecognizer_Tapped(object sender, EventArgs e)
    {

        Navigation.PopAsync(new Page1());

    }

PopAsync gives error in here: Argument 1 :Cannot Convert from Page1 to bool

Why is it giving error?

How to create button pressed effect?

$
0
0

Hello,

I need to create a button/image/whatever that changes image while pressed to create the button pressed effect. How can i get to the 'while pressed' state? Even if using custom renderers, i cant do it. Could some one give me some hints?

Thanks

Viewing all 89864 articles
Browse latest View live


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