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

Showing different DataTemplates depending on bindings.

$
0
0

In WPF I could use ContentControl => ContentTemplate =>Style TargetType => DataTemplate. And use triggers to bind to and get different controls depending on the data that is bound too. Is there a way to do this in Xamarin Forms.
Simple example

<DataTemplate x:Key="Details">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <StackPanel>
                    <Label
                        Margin="0"
                        Padding="0"
                        HorizontalAlignment="Left"
                        Background="Transparent"
                        BorderThickness="0"
                        Content="{Binding DataContext.Blah, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}" />           
                </StackPanel>
                <ListBox
                    Grid.Row="1"
                    ItemsSource="{Binding DataContext.Stuff, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}"
                    Visibility="{Binding DataContext.MoreStuff, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Converter=      {               StaticResource boolToVisibilityConv}}" />
            </Grid>
        </DataTemplate>
<DataTemplate x:Key="Options">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <StackPanel>
                    <Label
                        Margin="0"
                        Padding="0"
                        HorizontalAlignment="Left"
                        Background="Transparent"
                        BorderThickness="0"
                        Content="{Binding DataContext.Blah, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}" />           
                </StackPanel>
                <ListBox
                    Grid.Row="1"
                    ItemsSource="{Binding DataContext.Stuff2, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}"
                    Visibility="{Binding DataContext.MoreStuff2, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}, Converter=     {               StaticResource boolToVisibilityConv}}" />
            </Grid>
        </DataTemplate>
 <Style x:Key="ContainerStyle" TargetType="ContentControl">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Body}" Value="Options">
                    <Setter Property="ContentTemplate" Value="{DynamicResource Options}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Body}" Value="Details">
                    <Setter Property="ContentTemplate" Value="{DynamicResource Details}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
<ContentControl Style="{StaticResource ContainerStyle}" />

My app is not displaying keyboard

$
0
0
I am having issues when my app is not displaying the keyboard on Huawei phones. User tap the screen but keyborad screen not showing up. What could it be?

Build errors after Visual Studio for Mac update

$
0
0

After upgrading to the latest version of VS Community for Mac, my project no longer compiled. Also, I uninstalled and installed VS 2019, which also doesn't work. I get the following build error:

The primary reference "Plugin.Fingerprint" could not be resolved because it was built against the ".NETPortable,Version=v5.0" framework. This is a higher version than the currently targeted framework ".NETPortable,Version=v4.5,Profile=Profile111".

I noticed many people got this error from this same library in the past but none of the solutions worked for me. The Target Framework for my project was set to .NET Portable (PCL 4.5 Profile111).

When I changed the Target Framework to .NET Standard, I got many more errors like:

Package XLabs.Platform 2.0.5782 is not compatible with netstandard1.5 (.NETStandard,Version=v1.5). Package XLabs.Platform 2.0.5782 supports:
- monoandroid (MonoAndroid,Version=v0.0)
- portable-net45+win8+wp8 (.NETPortable,Version=v0.0,Profile=Profile78)
- portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
- wp8 (WindowsPhone,Version=v8.0)
- wpa81 (WindowsPhoneApp,Version=v8.1)
- xamarinios10 (Xamarin.iOS,Version=v1.0)

Needless to say, I'm open to many suggestions. I've tried to go back to a previous version of VS for Mac but can't find them. Also, TIme Machine wasn't enabled so I can't rollback the machine. As you can see from the error, switching from .NET Portable to .NET Standard caused even more errors. I've also tried deleting bin/obj/package folders, clean, rebuild etc. None of that has worked.

Any suggestions would be greatly appreciated.

OnCurrentPageChanged TabbedPage, infinite loop

$
0
0

Hello,
I have the same problem : https://stackoverflow.com/questions/54657758/how-to-set-the-currentpage-property-of-a-tabbedpage-in-the-oncurrentpagechanged

If I change the CurrentPage in OnCurrentPageChanged, I have an infinite loop. My client want a previous and next tab button...
They button change MVVM selected Item and I want to go back in the Children[1] (<- the loop)

    protected override void OnCurrentPageChanged()
    {
        base.OnCurrentPageChanged();
        if((this.CurrentPage == this.Children.First() || this.CurrentPage == this.Children.Last()) && !init_page)
        {
            this.view_model.CurrentItem = this.CurrentPage == this.Children.First() ? this.view_model.PreviousItem : this.view_model.NextItem;
            this.SelectedItem = this.Children[1]; // Boucle infinie
        }
    }
  1. Last Tab call OnCurrentPageChanged
  2. this.Children[1] call OnCurrentPageChanged
  3. Last Tab call OnCurrentPageChanged
  4. this.Children[1] call OnCurrentPageChanged
  5. ...

Thanks

Connect to backend web api on Android Emulator

$
0
0

Hi,

I'm using visual studio 2019.
I created new xamarin project, chose tabbed template and included backend web api.
I tested the app on android emulator, it worked perfectly when using MockDataStore class and returns a list of items.

Whenever I try to use AzureDataStore, the list returns No records.
I tested the link "http://10.0.2.2:5000/api/item" on emulator browser, it worked and return json items as expected.
I only can't get it worked inside the app.

Any idea?

Blank screen when navigating

$
0
0

We ran into strange bug on IOS. When using a master navigation page when we 'pop to root' we get stuck at a blank page. By blank page I mean there is no content (just white).

The page that causes this includes a customer full screen video render.
Could that be the cause ? If not, what could be the cause.

Our current work around is to replace the master navigation page completely. (App.MainPage = new...). This works, but causes a noticeable reload of our content which is less than satisfactory.

Draw a dot over an image

$
0
0

I am trying to add a dot on an coordinate image which represents a location based on two variables: the x, y values. I used SkiaSharp to get the dot but however, when I run it on my iPhone, it becomes like this:

But this is not what I want, I just want the surface keep the original version which is like this:

The following is the code about draw a dot and display it using SK:

Any one know how to fix it? Really new about Xamarin, Please help.

iOS SafeArea + WKWebview

$
0
0

Hello,

I have a WKWebview in a window without SafeArea because I want the content to be seen until the end of the screen.

To do this, I have created a CustomWebview by overriding the safeAreaInserts:

        public class CustomWKWebView : WKWebView {

        static UIEdgeInsets _safeAreaInserts = new UIEdgeInsets(0, 0, 0, 0);


        public CustomWKWebView(IntPtr handle) : base(handle) { }
        public CustomWKWebView(NSCoder coder) : base(coder) { }
        public CustomWKWebView(NSObjectFlag t) : base(t) { }
        public CustomWKWebView(CGRect frame, WKWebViewConfiguration configuration) : base(frame, configuration) { }

        public override UIEdgeInsets SafeAreaInsets => _safeAreaInserts;

        }

Yes, it works but ..

. I need something more: The device notch hides webview content.

I ned that side of webview that is under the notch keeps the "Margin" so that the content is not below the notch.

That is to say: I want webview cover the entire screen except under the notch.

Some ideas?


How to upload image in firebase realtime database using xamarin forms?

$
0
0
How to upload image in firebase realtime database,or how to bind url with firebase storage..can any1 help me?

BLE Sender&Receiver

$
0
0

Hi can anybody give me a specific instruction about how to send and receive message between iOS app and Bluetooth LE device?

I am using vs2017 and test by my iPhone, for now I think the connection works but have no idea how to write the sender and receiver, do check the GitHub with this example: https://github.com/aritchie/bluetoothle but couldn't understand. Googled a lot but everything looks roughly.

I have no experience with Xamarin and Bluetooth LE so can anyone give me a sample or give me a specific clear instruction?

Thank!

How hide "Title" of child on Tabbed Page

$
0
0

Hi,

with respect to "Title" of child of a Tabbed Page:

If I do not put the title as seen in the following xaml, It looks like this

I want align all the items, included the selected.

My XAML:

Image 1:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="#" xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core" xmlns:local="clr-namespace:#" android:TabbedPage.ToolbarPlacement="Bottom"> <TabbedPage.Children> <ContentPage IconImageSource="home.png" Title="A" /> <ContentPage IconImageSource="turist.png" /> <ContentPage IconImageSource="map.png" /> </TabbedPage.Children> </TabbedPage>

Image 2:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="#" xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core" xmlns:local="clr-namespace:#" android:TabbedPage.ToolbarPlacement="Bottom"> <TabbedPage.Children> <ContentPage IconImageSource="home.png" /> <ContentPage IconImageSource="turist.png" /> <ContentPage IconImageSource="map.png" /> </TabbedPage.Children> </TabbedPage>

It can?

Navigation doesn't works everywhere but on Android 9.0

$
0
0

I am trying to navigate with the following code. It works on iOS, Oreo, and KitKat, but not Pie. I have confirmed this with the emulator and a real device.

MainThread.BeginInvokeOnMainThread( () => Application.Current.MainPage = new MainPage() );

All I get is a white screen indicating a deadlock. If I remove the BeginInvokeOnMainThread() it works on Pie but not iOS.

I know best practice is to always perform UI tasks on the main thread, but am at a loss as to why this is happening. Anyone have any ideas?

What is the best way to render a WebView with Source as HtmlWebviewSource Html =

$
0
0

I am currently working on an app feature where I need to show text in HTML format from server side coming via REST APIs.

The size of the text/html content varies per row and I trying to show the data in a scroll view containing multiple WebViews inside a big stack layout

My single row component looks like this,

<ContentView x:Name="RowComponent">

    <Grid>

        <Grid.RowDefinitions>

                    <RowDefinition Height="Auto" />

                    <RowDefinition Height="Auto" />

                    <RowDefinition Height="*" />

        </Grid.RowDefinitions>

        <Label Grid.Row=0/>

        <Label Grid.Row=1/>

        <WebView Grid.Row=2>

            <WebView.Source>

                <HtmlWebViewSource Html="{Binding FormattedMessage}" />

            </WebView.Source>

        </WebView>

    </Grid>

<ContentView>

And also the rows are repeated inside a content page like the following,

<ContentPage>

    <ScrollView>

        <StackLayout>

            <StackLayout>

                <StackLayout />

                <StackLayout>

                    <!-- Inside this there are multiple rows of the above component '**RowComponent**' -->

                </StackLayout>

            </StackLayout>

            <StackLayout/>

        </StackLayout>

    </ScrollView>

</ContentPage>

According to the Xamarin Forms documentation about WebView: "Grid without WidthRequest & HeightRequest. Grid is one of the few layouts that does not require specifying requested heights and widths." (Xamarin.Forms WebView Layout)

However, the WebView is not even showing up or showing any content. How can I fix this?

Thank you in advance.

Xamarin Forms: Push notification is not receiving to ios device

$
0
0

I have done the following things:

  1. Created a project in FCM console and added ios project into it.
  2. Downloaded the GoogleService-Info.plist and added it to the xamarin forms ios project directory and set the build action as Bundlesource.
  3. On Info.plist enabled remote notification background mode.
  4. Added FirebaseAppDelegateProxyEnabled in the app’s Info.plist file and set it to No.
  5. Created a provisioning profile and distribution certificate and installed it into the keychain access. Also, mapped these certificates in the project options.
  6. Uploaded .p12 certificate in FCM console.
  7. Added codes for handling push notification in AppDelegate.cs.

My Code:

    [Register("AppDelegate")]
    public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
    {
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App("",""));
            RequestPushPermissionsAsync();
            _launchoptions = options;
            return base.FinishedLaunching(app, options);
        }
        NSDictionary _launchoptions;
        public override void OnActivated(UIApplication uiApplication)
        {
            base.OnActivated(uiApplication);
            if (_launchoptions != null && _launchoptions.ContainsKey(UIApplication.LaunchOptionsRemoteNotificationKey))
            {
                var notfication = _launchoptions[UIApplication.LaunchOptionsRemoteNotificationKey] as NSDictionary;
                PresentNotification(notfication);
            }
            _launchoptions = null;
        }

        async Task RequestPushPermissionsAsync()
        {
            var requestResult = await UNUserNotificationCenter.Current.RequestAuthorizationAsync(
                 UNAuthorizationOptions.Alert
                | UNAuthorizationOptions.Badge
                | UNAuthorizationOptions.Sound);

            bool approved = requestResult.Item1;
            NSError error = requestResult.Item2;
            if (error == null)
            {
                if (!approved)
                {
                    Console.Write("Permission to receive notification was not granted");
                    return;
                }

                var currentSettings = await UNUserNotificationCenter.Current.GetNotificationSettingsAsync();
                if (currentSettings.AuthorizationStatus != UNAuthorizationStatus.Authorized)
                {
                    Console.WriteLine("Permissions were requested in the past but have been revoked (-Settings  app)");
                    return;
                }
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }
            else
            {
                Console.Write($"Error requesting permissions: {error}.");
            }
        }

        public async override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            if (deviceToken == null)
            {
                return;
            }
            Console.WriteLine($"Token received: {deviceToken}");
            await SendRegistrationTokenToMainPRoject(deviceToken);
        }

        async Task SendRegistrationTokenToMainPRoject(NSData deviceToken)
        {
            MessagingCenter.Send<object, string>(this, "fcmtoken", deviceToken.ToString());
        }

        public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
        {
            Console.WriteLine($"Failed to register for remote notifications: {error.Description}");
        }

        public override void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo,
            Action<UIBackgroundFetchResult> completionHandler)
        {
            PresentNotification(userInfo);
            completionHandler(UIBackgroundFetchResult.NoData);
            try
            {
                UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
                NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary;
                var message = (aps[new NSString("webContentList")] as NSString).ToString();
                LoadApplication(new App("", message));
            }
            catch (Exception ex)
            {
                //LogInfo.ReportErrorInfo(ex.Message, ex.StackTrace, "AppDelegate-DidReceiveRemoteNotification");
            }
        }

        void PresentNotification(NSDictionary userInfo)
        {
            NSDictionary aps = userInfo.ObjectForKey(new NSString("aps")) as NSDictionary;

            var msg = string.Empty;

            if (aps.ContainsKey(new NSString("alert")))
            {
                msg = (aps[new NSString("alert")] as NSString).ToString();
            }
            if (string.IsNullOrEmpty(msg))
            {
                msg = "(unable to parse)";
            }
            MessagingCenter.Send<object, string>(this, App.NotificationReceivedKey, msg);
        }
    }

I am not using any NuGet packages in ios part. When running the project into a device, the FCM token generating part is working and I can see the fcm token on the VS console. I tried to send a test notification to a device from postman but getting InvalidRegistration error.

Postman Response

{
    "multicast_id": 8754155136812875313,
    "success": 0,
    "failure": 1,
    "canonical_ids": 0,
    "results": [
        {
            "error": "InvalidRegistration"
        }
    ]
}

Postman Body

 {
    "to" : "d20ad003 7473bfba 85dffc33 1534decf b4b886f1 c738878f fd7f2c60 d9dabc36",
 "collapse_key" : "type_a",
 "data" : {
     "body" : "Body of Your Notification in Data",
     "title": "Title of Your Notification in Title",
     "key_1" : "Value for key_1",
     "key_2" : "Value for key_2"
 },
 "notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification",
     "sound": "default",
     "content_available" : true
 }
}

I have completed the android part implementation and notifications are receiving when push from the postman. But getting InvalidRegistration error on postman and not receiving any notification in my ios device.

Anyone suggest a solution for this issue.

Thanks in advance.

How to show image when user click on collection view

$
0
0

I have a Collection view with a label and an image. I want to make the elements to have a checkmark when clicked (instead of the default behavior, which is to change the background color).

With the code below, when the user clicks on a line, the background color is changed to gray. However, the image with a checkmark is not showed, even though I have defined a setter for the image.

```xml

<ContentPage.Resources>
        <ResourceDictionary>
            <Style TargetType="Grid">
                <Setter Property="VisualStateManager.VisualStateGroups">
                    <VisualStateGroupList>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="Normal" />
                            <VisualState x:Name="Selected">
                                <VisualState.Setters>
                                    <Setter Property="BackgroundColor" Value="LightGray" />
                                    <Setter x:DataType="Image" Property="Image.Source" Value="icon_check.png" />
                                </VisualState.Setters>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateGroupList>
                </Setter>
            </Style>            
        </ResourceDictionary>
    </ContentPage.Resources>


//

<CollectionView 
                                x:Name="collectionview_cadastronotificacao_tipoocorrencia"
                                ItemsSource="{Binding TipoOcorrencia}" 

                                SelectionMode="Multiple" 
                                BackgroundColor="White" 
                                HorizontalOptions="Center" 
                                VerticalOptions="Center"
                                SelectionChanged="CollectionView_SelectionChanged" >

                    <CollectionView.ItemTemplate>
                        <DataTemplate>
                            <Grid Padding="10" >

                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />                                    
                                </Grid.RowDefinitions>

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />                                    
                                </Grid.ColumnDefinitions>

                                <Image 
                                   Grid.RowSpan="1"
                                   Grid.Column="2" />

                                <Label Grid.Column="0"
                                       Text="{Binding Descricao}"
                                       FontAttributes="Bold" FontSize="Small"/>

                            </Grid>
                        </DataTemplate>
                    </CollectionView.ItemTemplate>
                </CollectionView>
```

If I change <Setter x:DataType="Image" Property="Image.Source" to <Setter x:DataType="Image" Property="Source", an InvalidCastException is thrown.


xamarin forms: InvalidRegistration error in postman when try to send notification to ios device

$
0
0

I am implementing push notifications using FCM in my Xamarin.Forms project. In the iOS project, I am getting the fcmtoken from RegisteredForRemoteNotifications. When I am sending a notification for the token by Postman I am getting InvalidRegistration error. I already worked on the android part and notification is successfully delivered for android device.

AppDelegate.cs

public async override void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
        {
            if (deviceToken == null)
            {
                return;
            }
            Console.WriteLine($"Token received: {deviceToken}");
            await SendRegistrationTokenToMainPRoject(deviceToken);
        }

        async Task SendRegistrationTokenToMainPRoject(NSData deviceToken)
        {
            MessagingCenter.Send<object, string>(this, "fcmtoken", deviceToken.ToString());
        }

        public override void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
        {
            Console.WriteLine($"Failed to register for remote notifications: {error.Description}");
        }

Postman Response

{
    "multicast_id": 8754155136812875313,
    "success": 0,
    "failure": 1,
    "canonical_ids": 0,
    "results": [
        {
            "error": "InvalidRegistration"
        }
    ]
}

Postman Body

 {
    "to" : "d20ad003 7473bfba 85dffc33 1534decf b4b886f1 c738878f fd7f2c60 d9dabc36",
 "collapse_key" : "type_a",
 "data" : {
     "body" : "Body of Your Notification in Data",
     "title": "Title of Your Notification in Title",
     "key_1" : "Value for key_1",
     "key_2" : "Value for key_2"
 },
 "notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification",
     "sound": "default",
     "content_available" : true
 }
}

I am not using any NuGet packages like FirebasePushNotificationPlugin in IOS. I am receiving the devicefcmtoken in log but pushing from postman results InvalidRegistration error.

Found the same thread here, So I installed FirebasePushNotificationPlugin in IOS and capture the devicefcmtoken by the following code, but FirebaseInstanceIdcould not be found error is getting.

var fcmToken = FirebaseInstanceId.Instance.Token;

How can I solve this issue?

Binding Resource Key ( in a Multilingual app) with StringFormat option.

$
0
0

Hi guys,

Has anyone tried binding the resource Keys with the StringFormat options?
I have a label like :

<Label Text="{Binding CurrAge, StringFormat='Current age: {0}'}" />

While the above works goof for English version.
I am planning to add Resource keys for a multi-lingual application.
I do not know how to use both StringFormat and ResourceKey at once,

For example

// keyCurrAge is key which holds value => 'Current age: {0}'
<Label Text="{Binding Resources[keyCurrAge]}" />

I tried following, but not working

<Label Text="{Binding Resources[keyCurrAge] , StringFormat='Current age: {0}'}" />

Any ideas, thoughts? (Other than using two different labels, please)

Regards,
N Baua

Databinding to controledTemplate and contentPage

$
0
0

Hi, I have created controlled template to which I bind some properties. Then I have Main view which Is a page to which I need to bind one class to render realtime data.

Problem is that when I use bindablecontext=myclass; IT breaks the other databinding which goes to template.

Here is the code

<?xml version="1.0" encoding="utf-8" ?>
<Application"
             xmlns:x=""
             xmlns:custom="clr-namespace:HOT_App.Components"
             x:Class="HOT_App.App">
    <Application.Resources>

        <ResourceDictionary>

            <ControlTemplate x:Key="appLayout">

                <!-- Template file -->
                    <!-- Grid definition -->
                <Grid BackgroundColor="#e4e4e4" ColumnSpacing="0" RowSpacing="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                        <Grid.RowDefinitions >
                            <RowDefinition Height="65"></RowDefinition>
                            <RowDefinition  Height="*"></RowDefinition>
                        </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>

                        <ColumnDefinition Width="1.5*"></ColumnDefinition>
                            <ColumnDefinition Width="9*"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <!-- Children's of the grid. -->

                        <!-- Place for background. -->
                    <StackLayout   BackgroundColor="#252a54"  Grid.Row="0">
                        <BoxView HeightRequest="10" BackgroundColor="#009de0"></BoxView>
                    </StackLayout>
                    <!-- Place for logo and treatment profile. -->
                        <StackLayout Spacing="0" BackgroundColor="#252a54" Grid.Column="1">
                          <BoxView Margin="0" HeightRequest="10" BackgroundColor="#009de0"></BoxView>
                          <Grid Margin="0" Padding="0" BackgroundColor="#0f1d3f" ColumnSpacing="0" RowSpacing="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                            <Grid.RowDefinitions >
                              <RowDefinition Height="55"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                              <ColumnDefinition ></ColumnDefinition>
                              <ColumnDefinition ></ColumnDefinition>
                              <ColumnDefinition ></ColumnDefinition>
                            </Grid.ColumnDefinitions>

                            <BoxView BackgroundColor="#252a54" Grid.Column="0" Grid.ColumnSpan="3"/>

                            <Image  Margin="0,-20" Grid.Column="1" TranslationY="10" TranslationX="-20" HorizontalOptions="Center" Source="o2matic_logo.png" />
                            <Frame  Padding="3"  Grid.Column="2" HorizontalOptions="End" HeightRequest="50" WidthRequest="150" BackgroundColor="#009de0">
                              <FlexLayout AlignItems="Center" JustifyContent="Center"  WidthRequest="150" HeightRequest="50" BackgroundColor="#252a54" >

                                    <Label WidthRequest="150" FontSize="20" TextColor="White"  VerticalTextAlignment="Center" HorizontalTextAlignment="Center"  Text="{TemplateBinding Parent.BindingContext.UserData.TreatmentProfile.TreatmentProfileName}" />
                              </FlexLayout>
                            </Frame>

                          </Grid>


                        </StackLayout>

                        <!-- Place for name, battery,navigation, udsn. -->
                        <StackLayout  Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" >

                            <!-- Name -->
                            <Frame WidthRequest="225" BackgroundColor="#26272d" HeightRequest="105"  TranslationX="-25" TranslationY="-25" CornerRadius="25"
                                Padding="0"
                                Margin="-25,0">

                            <Label TranslationX="25"  TranslationY="10" FontSize="24" TextColor="White"  VerticalTextAlignment="Center" HorizontalTextAlignment="Center"  Text="{TemplateBinding Parent.BindingContext.UserData.FirstName}" />
                        </Frame>
                            <!--Battery-->
                        <Frame  TranslationX="-25" WidthRequest="225" BackgroundColor="#26272d"   CornerRadius="25"
                                    Padding="0"
                                    Margin="-25,0" TranslationY="-15">
                            <StackLayout TranslationX="20"  Spacing="0">
                                <Label Margin="5" FontSize="Medium" TextColor="White"  VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Text="Battery"/>
                                <BoxView  HeightRequest="2" Color="Gray"></BoxView>
                                <FlexLayout Direction="row" JustifyContent="Center" AlignContent="Center" AlignItems="Center">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="50" />
                                        </Grid.RowDefinitions>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                        </Grid.ColumnDefinitions>
                                        <BoxView TranslationX="6" Margin="0,12" HorizontalOptions="Start" WidthRequest="{TemplateBinding Parent.BindingContext.BatteryStatus.BatteryLevelRenderer}" Grid.Column="0" Grid.Row="0"  BackgroundColor="White" HeightRequest="50"/>
                                        <Image WidthRequest="65" Grid.Column="0" Grid.Row="0" HorizontalOptions="Center" Source="battery.png" />

                                    </Grid>

                                    <Label Margin="10,0,0,0" FontSize="Large" TextColor="White"  VerticalTextAlignment="Start" HorizontalTextAlignment="Center" Text="{TemplateBinding Parent.BindingContext.BatteryStatus.BatteryPercantage}"/>
                                </FlexLayout>

                                </StackLayout>
                            </Frame>
                        <!--Navigation-->
                        <Frame TranslationX="-25"  WidthRequest="225"  BackgroundColor="#26272d"  VerticalOptions="FillAndExpand" CornerRadius="25" Margin="-25,0">
                            <StackLayout TranslationX="25">
                                <BoxView HorizontalOptions="Fill" BackgroundColor="Black" HeightRequest="2"/>
                                <!--Navigation loop-->
                                <ListView VerticalOptions="Start" SeparatorVisibility="Default" SeparatorColor="Black"  RowHeight="50"
                                    ItemsSource="{TemplateBinding Parent.BindingContext.AppNavigation.NavigationItems}">
                                    <ListView.ItemTemplate >
                                        <DataTemplate>
                                            <ViewCell>
                                                <Grid ClassId="{Binding NavigationItemName}"   HorizontalOptions="Center" >
                                                <Grid.ColumnDefinitions >
                                                    <ColumnDefinition Width="1*" />
                                                    <ColumnDefinition  Width="Auto"/>
                                                    <ColumnDefinition Width="1*"/>
                                                </Grid.ColumnDefinitions>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="45" />
                                                    <RowDefinition Height="2" />
                                                </Grid.RowDefinitions>

                                                <Image WidthRequest="35" HorizontalOptions="End" VerticalOptions="Center" Source="{Binding Icon}" Grid.Row="0"  Grid.Column="0"/>
                                                    <Label VerticalTextAlignment="Center" TextColor="White" FontSize="Large" HorizontalTextAlignment="Center" Text="{Binding NavigationItemName}" Grid.Row="0"  Grid.Column="1"/>
                                                    <Image IsVisible="{Binding Active}" WidthRequest="25" HorizontalOptions="End" Source="activeNavigation.png" Grid.Row="0"  Grid.Column="2"/>


                                                <Grid.GestureRecognizers>
                                                        <TapGestureRecognizer CommandParameter="{Binding NavigationItemName}"  Tapped="NavigationHandler"/>
                                                </Grid.GestureRecognizers>

                                            </Grid>

                                            </ViewCell>

                                        </DataTemplate>
                                    </ListView.ItemTemplate>
                                </ListView>
                                <!--Navigatio loop-->

                                <BoxView HorizontalOptions="Fill" BackgroundColor="Black" HeightRequest="2"/>
                                <Frame Padding="0" BackgroundColor="Transparent"  WidthRequest="225" VerticalOptions="EndAndExpand" >
                                    <StackLayout WidthRequest="225" HorizontalOptions="FillAndExpand" >
                                        <BoxView HorizontalOptions="Fill" BackgroundColor="Black" HeightRequest="2"/>
                                        <Label VerticalTextAlignment="Center" TextColor="White" FontSize="Default" HorizontalTextAlignment="Center" Text="UDSN"/>
                                        <Label BackgroundColor="Gray" VerticalTextAlignment="Center" TextColor="White" FontSize="Default" HorizontalTextAlignment="Center" Text="{TemplateBinding Parent.BindingContext.deviceData.UDSN}"/>
                                    </StackLayout>

                                </Frame>
                            </StackLayout>
                        </Frame>

                    </StackLayout>


                        <!-- Place for vital's, treatment, warnings. -->
                        <StackLayout Margin="10, 30, 10, 10"  Grid.Row="1" Grid.Column="1">
                        <ContentPresenter></ContentPresenter>
                        </StackLayout>
                    </Grid>
            </ControlTemplate>
        </ResourceDictionary>
    </Application.Resources>
</Application>





using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using HOT_App.Services;
using HOT_App.Views;
using HOT_App.ViewModels;
using System.Collections.ObjectModel;
using ProgressBar = HOT_App.ViewModels.ProgressBar;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
namespace HOT_App
{
    public partial class App : Application
    {

        //TODO: Replace with *.azurewebsites.net url after deploying backend to Azure~~~~
        public static bool UseMockDataStore = true;
        Navigation AppNavigation = new Navigation();
        Battery BatteryStatus = new Battery();
        ApplicationBindings ApplicationBind { get; set; }

        public App()
        {
            InitializeComponent();


            TreatmentProfile treatmentProfile = new TreatmentProfile("2","COPD_NORal");
            UserData UserData = new UserData("ID789456789","Matuska","English","Denmark","31858585","38585848", treatmentProfile);
            DeviceData DeviceData = new DeviceData("UDSN12213213");
            ApplicationBind = new ApplicationBindings(AppNavigation, BatteryStatus, UserData, DeviceData);
            VitalsData VitalsData = new VitalsData(70, 6.1, 92);


            BatteryStatus.BatteryLevelChange(50);

            this.BindingContext = ApplicationBind;
            if (UseMockDataStore)
                DependencyService.Register<MockDataStore>();
            else
                DependencyService.Register<AzureDataStore>();
            //this.BindingContext = AppNavigation;
            MainPage = new NavigationPage(new Main());



        }

        protected override void OnStart()
        {

            // Handle when your app starts
        }

        protected override void OnSleep()
        {
            // Handle when your app sleeps
        }

        protected override void OnResume()
        {
            // Handle when your app resumes
        }

        // Navigation controler->>> works with AppNavigation<Navigation>
        private void NavigationHandler(object sender, EventArgs e)
        {
            Grid gridSender = (Grid)sender;
            if (gridSender.GestureRecognizers.Count > 0)
            {
                var gesture = (TapGestureRecognizer)gridSender.GestureRecognizers[0];
                var activeNav = (string)gesture.CommandParameter;
                AppNavigation.SetActiveNavigation(activeNav);
            }

            AppNavigation.ShowActiveNavigation();

        }
    }
}

MAin.cs

using HOT_App.ViewModels;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using ProgressBar = HOT_App.ViewModels.ProgressBar;

namespace HOT_App.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class Main : ContentPage
{

    public Main ()
    {

        InitializeComponent();
        VitalsData VitalsData = new VitalsData(70, 6.1, 92);
        this.SetBinding(BindableProperty.Create("AppBindings", typeof(Navigation), typeof(ApplicationBindings)), "AppBindings");

        //this.SetBinding(BindableProperty.Create("BatteryStatus", typeof(Battery), typeof(Main), new Battery()), "BatteryStatus");




        this.SetBinding(BindableProperty.Create("VitalsData", typeof(VitalsData), typeof(VitalsData), VitalsData), "VitalsData");

        DateTime newMeasurementTime = new DateTime(2019, 07, 02, 13, 31, 30);


        Measurement newMeasurement = new Measurement(newMeasurementTime, mainStackLayout);
        newMeasurement.CreateCountdown();



        //StackLayout testing=newMeasurement.DisplayCountdown_StartOfMeasurement();
        //mainStackLayout.Children.Add(testing);





    }
}

}~~~~

Working with disk space info in forms.

$
0
0

Hello guys!
Is there any forms library that allows us to work with disc space stats? Like available disk space, used disk space etc.

Thanks!

How To access To parameters of the device

$
0
0
Hi everyone,
How To redirect To this type of page ?

Thx :)
Viewing all 81910 articles
Browse latest View live


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