Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

How to get Absolute Layout and Relative Layout to Autosize to the size of their child element

$
0
0

The design requirement is to put a label and a button on the image. The Image is in a DataTemplate of ListView. I want to use Absolute Layout. But it expand way out of the child element (image). So how to make the absolute layout the same size of the image. On the other hand if I use relative layout it also expands out of the child element. But it takes less space than absolute layout. I know Absolute Layout and RelativeLayout are the best for this scenario. But they were leaving lots of empty space between list view items. Please help me out and explain how to use both of these layouts appropriately in order to size them according to their child elements. The code is as follows


<ListView.ItemTemplate>

                     <AbsoluteLayout >

                        <Image Source="BuyersCard.png" > </Image>

                       <Label Text="{Binding Name}" AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds=".1,.2"></Label>

                            <Button Text="Contact" BorderColor="Red" AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds=".7,.2"></Button>

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

    </ListView>

Add InsertCommand to dataAdapter with SqliteCommandBuilder

$
0
0

I'm trying to generate InsertCommand to SqliteDataAdapter but got this error:

Unhandled Exception:
System.InvalidOperationException: Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information.

This is my code:

using Mono.Data.Sqlite; 

public void Test(){
  var dataAdapter = new SqliteDataAdapter();
  var dataSet = new DataSet("TestTable");

  SqliteCommandBuilder commandBuilder = new SqliteCommandBuilder(dataAdapter);

  SqliteConnection connection = new SqliteConnection();
  connection.ConnectionString = "Data Source=" + dbPath;
  connection.Open();

  dataAdapter.SelectCommand = connection.CreateCommand();
  //dataAdapter.SelectCommand.CommandText = "SELECT * FROM TestTable";
  dataAdapter.SelectCommand.CommandText = "SELECT [ID], [Name] FROM TestTable";

  dataAdapter.InsertCommand = commandBuilder.GetInsertCommand(); // ERROR
}

Create table script:

CREATE TABLE `TestTable` (
    `ID`    INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    `Name`  TEXT NOT NULL
);

Data in table

1 'Pedro'

Any help?

Selection of multiple images from Gallery.(Xamarin forms)

$
0
0

Unable to select multiple images from android gallery.
I was able to perform multi select images from iOS using Dependency service, but in android i achieved multiple selection using native code to an extent, but there are certain gallery folders say, FILE MANAGER or SDCard and so on dint support multi selection of images.
Please help.

binding model string to x:name for form element in xaml

$
0
0

How to bind a binding context string to a element x:name and get that element in click element?

Eg :

Any help is truly appreciated

How to set up the input method correctly für the phone input panel?

$
0
0

Hi there,

I am having problems with the "phone" input type. If i choose this the input panel looks right for my purpose, but I could not enter any characters. So they are inactive and I could only use the numbers. As for the user should only input a few characters and way more numbers, I thought the "phone" input type is the right one.

The system I am using runs under Android 4.4.

May this be the problem?

Thank you in advance

Xamarinion

AbsoluteLayout not working as expected

$
0
0

Hi Folks,

I have some very weird placement of controls with absoluteLayout. The whole thing looks buggy to me actually. Instead of giving an example from my own code, please see this page: https://adventuresinxamarinforms.com/2015/05/05/demystifying-xamarin-forms-absolutelayout-and-relativelayout-positioning/

From that page, it's this portion that perfectly explains my question:

Oh dear! That’s not what I expected. The BoxView is offset so that it falls short of the correct x and y positions. Why has this happened? It took me a while to wrap my head around this but essentially the AbsoluteLayout also takes into account the size of the control when calculating the relative x and y position. In other words it is 25% of the AbsoluteLayout less the size of the control. Why would it do this? That’s a good question.>

It boils down to this. The box generated from these 2 separate ways of placing color on a form should be in the exact same position but they are not:

The red box is correct:
<Grid RowSpacing="0" ColumnSpacing="0"> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="*" /> <RowDefinition Height="*" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <BoxView Grid.Row="1" Grid.Column="1" BackgroundColor="Red" /> </Grid>

This yellow box is not correct:
<AbsoluteLayout Opacity="0.75"> <BoxView Color="Yellow" AbsoluteLayout.LayoutBounds="0.25,0.25,0.25,0.25" AbsoluteLayout.LayoutFlags="All" /> </AbsoluteLayout>
I think there must be a bug with AbsoluteLayout. Does anyone agree?

Thanks for your help.

Mike

AbsoluteLayout - how to put a StackLayout 30% from the top of the page

$
0
0

Hi,
I've an issue, which probably is very easy to solve, but I have no idea how to do it. I want to have a StackLayout element (100x100), so that its top border would be at 30% of a page.

I wrote this XAML:
<?xml version="1.0" encoding="utf-8" ?>

  <AbsoluteLayout>
    <StackLayout AbsoluteLayout.LayoutBounds="0.5,0.3,100,100" AbsoluteLayout.LayoutFlags="PositionProportional" BackgroundColor="Yellow">

    </StackLayout>  
  </AbsoluteLayout>

</ContentPage>

Unfortunately, my StackLayout is drawn at about 28% from the top of the page. What's the reason for that?

To be honest, I don't really understand how positioning in AbsoluteLayout works.
If I set AbsoluteLayout.LayoutBounds="0,0.3,100,100" AbsoluteLayout.LayoutFlags="PositionProportional" my StackLayout is drawn on the left (the left border of it is in contact with the left side of the page).
If I set AbsoluteLayout.LayoutBounds="1,0.3,100,100" AbsoluteLayout.LayoutFlags="PositionProportional" my StackLayout is drawn on the right (the right border of it is in contact with the right side of the page). And that's weird - I thought it would be drawn outside of the screen.

Which point of the element is the one that we set the position for? In other words: When I set X position of a StackLayout to be 0.3 (PositionProportional), which point of this StackLayout should be positioned at 0.3 - is it the top-left corner? Or maybe the centre of the StackLayout? I can't figure it out.

I hope you understand my issue and can help me.

Auto logout after x minutes due to idle/inactivity in android

$
0
0

Is there way on how to auto logout the session of the user, when the user is idle or not clicking the app? Thank you.


Xamarin forms: Hide Flowlistview item including it's space from UI based on a string value.

$
0
0

I am using flowlistview for listing images. I need to hide the image if pageStatus value is OFF and show the image if pageStatus value is ON. I tried like below:

In model:

public string pageStatus { get; set; }
public bool pictureStatus
        {
            get
            {
                if (pageStatus == "OFF")
                    return false;
                else
                    return true;
            }
        }

In XAML added IsVisible="{Binding pictureStatus}" for the image. The images are not showing in the UI but blank spaces are showing for OFF status pictures like below.

enter image description here

I need to remove that blank space also from the UI, how can I do that?

images and graphs are not showing

$
0
0
   <Image Aspect="AspectFit"   Margin="0" HeightRequest="10" WidthRequest="10" Source="{local1:EmbeddedImage SmartFabricNew.images.date-icon.png}"/>

is there a way to check lockscreen enable or not?

$
0
0

hello everyone.
i need to make a project that can detect if password are being set or not on android in form of true or false.
can someone help me figure it out?
thank you

WatchOS 5.1 TCP Outgoing connection problem

$
0
0

Hello.

My Watch App call web service on https protocol in Internet.
I have always nw_resolver_create_dns_service_locked error:

WatchKit Extension[326:81502] dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
WatchKit Extension[326:81502] dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
WatchKit Extension[326:81502] dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
WatchKit Extension[326:81502] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:8 Err:-1 Errno:1 Operation not permitted
WatchKit Extension[326:81502] [] nw_resolver_create_dns_service_locked DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)
WatchKit Extension[326:81502] TIC TCP Conn Failed [1:0x1669aaa0]: 10:-72000 Err(-65563)
WatchKit Extension[326:81492] Task . HTTP load failed (error code: -1009 [10:-72000])
WatchKit Extension[326:81492] NSURLConnection finished with error - code -1009

I added to file
com.apple.security.network.client

but I have new error
ApplicationVerificationFailed: Failed to verify code signature of /private/var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.OPGbCB/extracted/Payload/isafereader.app : 0xe8008016 (The executable was signed with invalid entitlements.)
error MT1006: Could not install the application '/Users/dev/Projects/qaz/qaz/bin/iPhone/Release/qaz.app' on the device 'iPhone (Daniel)': Your code signing/provisioning profiles are not correctly configured. Probably you have an entitlement not supported by your current provisioning profile, or your device is not part of the current provisioning profile. Please check the iOS Device Log for details (error: 0xe8008016).

I checked provisioning options on developer.apple.com.
I have all permissions checked.

What am I doing wrong?

Call Command from Page.cs

$
0
0

Hi everyone

i have Login page with Button

private async Task ClickAsync(Button signinbutton)
{
signinbutton.IsEnabled = false;
RegisterButton.IsEnabled = false;
try
{
string HtmlText = GetHtmlFromUri("http://google.com");
if (HtmlText == "")
{
await DisplayAlert("خطأ", "لايوجد اتصال بالانترنت , يرجى المحاولة لاحقاً.", "حسناً");
}
else if (!HtmlText.Contains("schema.org/WebPage"))
{
//Redirecting since the beginning of googles html contains that
//phrase and it was not found
await DisplayAlert("خطأ", "لايوجد اتصال بالانترنت , يرجى المحاولة لاحقاً.", "حسناً");

            }
            else
            {
                UserDialogs.Instance.ShowLoading("");

                if (UsernameEntry.Text != null && PasswordEntry.Text != null)
                {
                    var AccessToken = await accountApi.Login(UsernameEntry.Text, PasswordEntry.Text);

                    if (AccessToken != null)
                    {
                        Settings.AccessToken = AccessToken;
                        UserDialogs.Instance.HideLoading();

                    ****    /// Here i want to call Command Login From ViewModel****
                    }
                    else
                    {
                        UserDialogs.Instance.HideLoading();
                        await DisplayAlert("تنبيه!!.", "خطأ في تسجيل الدخول", "حسنأ");
                    }

                }
                else
                {
                    UserDialogs.Instance.HideLoading();
                    await DisplayAlert("تنبيه!!", "فضلاً تأكد من الحقول", "حسنأ");
                }
            }
        }
        catch (Exception e)
        {
            await DisplayAlert("يرجى المحاولة لاحقاً.", e.Message.ToString(), "حسناً");
        }
        finally
        {
            UserDialogs.Instance.HideLoading();
            signinbutton.IsEnabled = true;
            RegisterButton.IsEnabled = true;
        }
    }

My View Model

public class SignInViewModel : BaseViewModel, ISignInViewModel
{
private INavigationService navigationService;
private string _email;
private string _error;
private string _password;

    public SignInViewModel()
    {
        var canLogin = this.WhenAny(x => x.Email, x => x.Password,
            (e, p) => !string.IsNullOrEmpty(e.Value) && !string.IsNullOrEmpty(p.Value));

        GoRegister = ReactiveCommand.CreateFromTask(async () =>
           await navigationService.NavigateAsync(typeof(ISignUpViewModel)));

        Login = ReactiveCommand.CreateFromTask(async () =>
            {
                await navigationService.NavigateToMainPage(typeof(IMainViewModel));
            }, canLogin);

    }


    public string Error
    {
        get => _error;
        set => this.RaiseAndSetIfChanged(ref _error, value);
    }

    public ICommand GoRegister { get; }


    public ICommand Login { get; } // **Calll This Command **


    public string Email
    {
        get => _email;
        set => this.RaiseAndSetIfChanged(ref _email, value);
    }

    public string Password
    {
        get => _password;
        set => this.RaiseAndSetIfChanged(ref _password, value);
    }

    public override string Title => "تسجيل دخول";
}

I tried execute() but not worked

my Goal is to navigation to another View Using navigation service

Any Help Please

Thanks in Advance

Problem with Absolute Layout and Overlay Areas

$
0
0

Hi there!

I have a View with list view and, using absolute layout, I created an editor for that list view.

The editor, when visible, overlays itens 2 to 6.

I can tap or press itens 1 and 7 to call the editor.

If I tap itens 2 to 6, nothing happens. The editor, even invisible, block my selection.

Is there a way to fix this problem?

Thanks in advance for any kind of help.

Regards,

Ciro.

Navigating and Navigated events of webView not working on Android

$
0
0

I am using navigating and navigated events of webView in xamarin forms, these events working fine on ios but on android when page load these event does'nt work. I am using these events to add busy indicator


Tabbed Bar Tricks for iOS

$
0
0

Hello,

I am using a Tabbed Page for my main page and added icons for each content page. On Android those icons looks very nice, but same Icons on iOS looks awful.

For those icons, I am using png files. What types of image / icon types are you using and which can you recommend?

What does mean iOS Icons look awful?

Here is it in android:

You can see, icons are white and even other colors are displayed.

How it looks on iOS:

I am using xaml xml to specify the source of those icons.

<ContentPage x:Name="contentPage_ABC" BackgroundColor="White" Icon="MyIcon.png">

Thanks for all tipps !

Missing required Icons

$
0
0

Hi,

we have a problem uploading our app to the iOS app store for some days now. Actually it is a Forms App but hope it's still correct in this forum.
The app was working before but since we updated to Mojave and updated some of the Xamarin stuff there seems to be problem in building the asset catalog.
When trying to upload the ipa to the app store we get errors like:

ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '76x76' pixels, in .png format for iOS versions >= 7.0."
ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '167x167' pixels, in .png format for iOS versions supporting iPad Pro."
ERROR ITMS-90023: "Missing required icon file. The bundle does not contain an app icon for iPad of exactly '152x152' pixels, in .png format for iOS versions >= 7.0."

We already deleted bin/obj folders. Recreated the asset catalog. Checked the path in info.plist.
Everything seems to be fine.

I could figure out that the Assets.car that is created in copied to the ipa is empty or includes a default Xamarin Forms image.
I checked my build output and there are two entries related to the Assets.car:

    Copying file from '/Users/.../iOS/obj/iPhone/Release/actool/bundle/Assets.car' to '/Users/.../iOS/bin/iPhone/Release/....iOS.app/Assets.car'

and later:

    Copying file from '/Users/.../iOS/obj/iPhone/Release/Assets.car' to '/Users/.../iOS/bin/iPhone/Release/....iOS.app/Assets.car'

This makes actually no sense to me. The first copies the correct file to the bin path with the related assets. The second seems to copy an empty template file. Does that make sense to anyone? Is it possible to change the build process or is the actool building incorrect?

Any help is appreciated.

Chris.

iOS : ToolbarItems not displaying on root navigation page

$
0
0

Hello all,

I got three toolbaritems in my app which display everywhere on Android.
Prob is on iOS it only shows on pages which are pushed in the navigationPage. When I'm on the root page of the navigation page, they don't display. How to force iOS to show them even if I'm on the root of the navigationPage ?

Thanks.

     var toolbarItem = new ToolbarItem
            {
                Order = ToolbarItemOrder.Secondary,
                Priority = 0,
                Text = "Help"
            };
            var toolbarItem2 = new ToolbarItem
            {
                Order = ToolbarItemOrder.Secondary,
                Priority = 1,
                Text = "Support"
            };
            var homeToolBar = new ToolbarItem
            {
                Order = ToolbarItemOrder.Primary,
                Priority = 0,
                Icon = "ic_home_black_18dp"
            };

WatchConnectivity, Session, Watch iPhone

$
0
0

I am trying to implement communication between WatchExtension and iOS App. I would like every time I press the UI button on Apple Wach to follow the method on the iOS application side (regardless of whether the application is in the background or in the foreground).

Will you help me find an example of such communication?

CMSampleBuffer Attachment Setting

$
0
0

Trying to set DisplayImmediately setting but cannot se how, got so far...

CMSampleBufferAttachmentSettings[] sampleBufferAttachmentSettings = sampleBuffer.GetSampleAttachments(true);
sampleBufferAttachmentSettings[0].DisplayImmediately = true;

Viewing all 204402 articles
Browse latest View live


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