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

FreshMVVM and SwitchOutRootNavigation

$
0
0

Hi All!

I use Xamarin Forms and freshmvvm. I have a login page, after login I push next page, let's say Page1, which I'd like to be root from now on. So after navigation to a few other pages I'd like to be able to get back to Page1, calling CoreMethods.PopToRoot. When logging out, I'd like to go back to login page and clear all the navigations stacks. This is what I tried so far:

public class NavigationStacks
{
public static string LoginNavigationStack = "LoginNavigationStack";
public static string MainAppStack = "MainAppStack";
}

public App()
{
var page = FreshPageModelResolver.ResolvePageModel();
var basicNavContainer = new FreshNavigationContainer(page, NavigationStacks.LoginNavigationStack);

 var page2 = FreshPageModelResolver.ResolvePageModel<CustomerSearchPageModel>();
 var appNavContainer = new FreshNavigationContainer(page2, NavigationStacks.MainAppStack);
 MainPage = basicNavContainer;

}

After login, I call:

CoreMethods.SwitchOutRootNavigation(NavigationStacks.MainAppStack);
await CoreMethods.PushPageModel();
And it works. I'm back on Page1 and can't get back to login page.

On logout I call:

CoreMethods.SwitchOutRootNavigation(NavigationStacks.LoginNavigationStack);
But nothing happens. I'd like to be navigates back to login page with navigation stack cleared. I believe I miss something. Can anyone help? Thanks in advance!!

Krzysztof


WebView is not loading URL in UWP

$
0
0

Hello,

I have a simple project in which I load a URL on a WebView. It is working as expected on Android, but on UWP, the WebView doesn't load anything and keep in blank.

It's not a problem of Width/Height as I have changed the background color and I can check it. Furthermore, I tried with a sample project of the docs, and it isn't working too. I don't know what's happening and I can't see nothing in the Output.

I'm using the latest version of Visual Studio 2019 and Xamarin.Forms. Already checked 'Internet Client & Server' Capabilities on UWP properties.

Someone knows what could I do to solve this?

Auto size custom ViewCell based on its contents, inside a TableView

$
0
0

Hi,
Ive seen similar ListView based questions but noting TableView related. I have the following:

TableView
UnevenRows = true
TableSection
TableSection etc
TableSection
MyViewCell
Grid with 3 columns, middle column is a word wrapping label

No matter what I do I cannot get the MyViewCell to autosize to its contents. I can explicitly set the height of the cell but I won't know it ahead of time. The grid and label in the MYViewCell has VerticalOptions = LayoutOptions.FillAndExpand, in fact Ive tried adding that to everything that takes it in the entire stack.

Is this situation not supported? Crazy if not.

Cheers
John

Adding image with PDFSharp Exception

$
0
0

Hi!

I'm using PDFSharp to create a PDF to be saved on my phone. I'm experimenting a bit with the possibilities, so I added to some text and a rectangle, and I played a bit with the use of colors. Everything works so far, including the saving part.
However, when I want to add an image I get an exception which I cannot solve:

I have added my code to Notepad++, which you can find in the attachment (language is C#).

I hope someone can help!

Xamarin Forms ListView isn't visible?

$
0
0

Hello,
at first thank you very much for your time. I created a ListView in Xamarin Forms and it worked perfectly. Today I tried to make a few changes and I also wanted to add an image. The image nearly covered the whole screen so I deleted this one. Now I have the problem, that my ListView is there, but it is so small that you only see a few yellow pixels in the center. The rest of the screen is white. Can anybody recognize an error here? Sorry for such questions! :/

        <ListView x:Name="ContactsList" ItemsSource="{Binding Source={x:Reference ContactsList}, Path=BindingContext.MyList}" IsVisible="True" MinimumHeightRequest="500" HasUnevenRows="True">
            <ListView.Header>
                <StackLayout Orientation="Horizontal">
                </StackLayout>
            </ListView.Header>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <ViewCell.ContextActions>
                        </ViewCell.ContextActions>
                        <StackLayout Orientation="Vertical">
                            <Label Text="{Binding Name}" FlowDirection="LeftToRight" FontAttributes="Bold" Margin="15,0,0,0" LineBreakMode="WordWrap" TextType="Text"></Label>
                            <Label Text="{Binding Address}" Margin="15,0,0,0"></Label>
                            <Button Text=" Clicked="Button_Clicked" BackgroundColor="Yellow"></Button>
                            <Button Text="" Clicked="Button_Clickedv" BackgroundColor="Yellow"></Button>
                            <Button Text="" Clicked="Button_Clickedo" BackgroundColor="Yellow"></Button>
                            <Button Text="" Clicked="Button_Clickeds" BackgroundColor="Yellow"></Button>
                            <Button Text="" Clicked="Button_Clickedi" BackgroundColor="Yellow"></Button>
                            <Button Text="" Clicked="Button_Clickedw" BackgroundColor="Yellow"></Button>
                            <Button Text="" Clicked="Button_Clickedf" BackgroundColor="Yellow"></Button>
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

how to detect press enter key when focus is in a Entry

$
0
0

Hi
how to detect press enter key in xamarin forms (uwp)?
I want to call a Command in View Model after enter on keyboard click when focus is in a Entry?

same code used in the same class many times

$
0
0

Hellooooo
Please help me in reducing the number of lines in a class page

I have the same code to be used in different if statements.

How can I use one word to replace the code each time needed?

Bluetooth classic implementation for Android(No BLE)?

$
0
0

Hi all, I would like to know how to implement classic bluetooth with xamarin. Would you have a link for me to look at?


How to resolve ArgumentException: Failed to parse PList data type

$
0
0

After updating Visual Studio to 15.6 today on my Windows PC, and updating Visual Studio and XCode on the Mac, I am getting the following when trying to build my app for iOS. Does anybody know how to resolve this?

AggregateException: One or more errors occurred.
MessagingRemoteException: An error occured on client Build490752 while executing a reply for topic xvs/Build/4.9.0.752/execute-task/MyApp.iOS/e164987002fIBTool
ArgumentException: Failed to parse PList data type:
ArgumentException: Must specify valid information for parsing in the string.

Xamarin UI.test is not accepting AutomationId

$
0
0

I am really new to this topic. Our Application is built using Xamarin Forms. I want to write automated UI tests using Xamarin UI.test. I created my test project using Xamarin Cross platform option, I have template Test.cs. I hooked everything to our app (so for example when i use app.SwipeRightToLeft(); it works on emulator).

However when I try to interact with button which has "AutomationId" it is not working. I have automation Id for button:

But in test when I try to do-> app.Tap("BFeriedage");

it just doesn't work. I have an error that it is not able to find element. I found out that it accepts "Title" but not "AutomationId". In every tutorial I watched they are just passing "AutomationId" in Tap method.

Can you help me find out reason why AutomationId is not accepted by .Tap method?

THanks

How do you make the image occupy the notch area on iPhone X

$
0
0

I have an image element in my XAML

            <StackLayout>
                <Image source="image1.png"/>
            </StackLayout>

How do I make this image occupy the notch area on iPhone X.
A good example would be the Login Screen of the facebook app.
The facebook banner occupies the entire top area including the notch area of iPhone X.
I have attached a screenshot of the facebook app on iPhone X.
.

Any help would really be appreciated.

Thanks.

Custom context menu for ViewCell

Picker Selection Event

$
0
0

Hi,

I have a problem with xamarin form picker.
I need to have an event when the "done" (ios) or "ok" (android) button was clicked. Cause i want to open a popup when user select an item.
I only see a SelectedIndexChanged how is fire each time user stop scrolling (on iOS, can't see on android).

Anyone know how I can put an event when picker is closed ?

Selecting Text When Enrty is Focused

$
0
0

I want users to overwrite text when they focused to the Entry with some default Text. Placeholders doesn't work for me. I need to select the text whenever I click to Entry. Is its possible?

Do I need to create my own IValueConverter?

$
0
0

Hello,

I want to be able to detect phone numbers, email addresses, etc., in text entered by the user and provide a link/gesture for that text so the user can tap it. For example, if the user enters a phone number I want to underline the phone number and, when tapped, open the phone dialer.

Is there something built-in in Xamarin.Forms or Xamarin.Essentials that would detect such text or do I have to create my own IValueConverter?

Thanks in advance,
Mike


Change Transparent Navigation Bar Color and Time Color

$
0
0

I found this for a Transparent navigation bar .

https://xamgirl.com/transparent-navigation-bar-in-xamarin-forms/

Looks good but i have a question , in this picture the Backbutton is White and the rest like clock is black

And want to get this also white like this

Have BarTextColor="White"

<?xml version="1.0" encoding="utf-8" ?>
<NavigationPage 
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="Transparantnavigatiebar.CustomNavigationPage"
    xmlns:iOS="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
    iOS:NavigationPage.IsNavigationBarTranslucent="True"
    BarTextColor="White">
    <NavigationPage.BarBackgroundColor>
        <OnPlatform x:TypeArguments="Color">
            <On Platform="Android, iOS" Value="Transparent" />
        </OnPlatform>
    </NavigationPage.BarBackgroundColor>
</NavigationPage>

What do i ad to make the rest also White ?

label font attributes is not working properly. can anyone help me out?

$
0
0

i am creating a label with csharp after that adding label to stackLayout. text and alignments are working fine. but font attribute is not working.

        Label view = new Label
        {
            Text = "Hello",
            FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
            VerticalTextAlignment = TextAlignment.Center,
            HorizontalOptions = LayoutOptions.StartAndExpand,
            HorizontalTextAlignment = TextAlignment.Start,
            LineBreakMode = LineBreakMode.TailTruncation,
            FontAttributes = FontAttributes.Italic
        };

In-App camera function

$
0
0

Hi all,

My app uses the standard camera for taking pictures (iOS and Android), but since I want to change the behaviour of the camera itself I need to create an in-app camera. I took a look at the ConferenceVision example, which seems pretty good for me: https://github.com/microsoft/ConferenceVision . The user in my my app has to take a picture, view it, and if the picture is good enough send it to an API.

Problem is that I cannot get it working in my app. It doesn't show the camera permissions somehow (it doesn't ask for any permissions), which causes the app to not show the camera.

I made a simple demo in the attachment, I hope someone can help me with this.

Xamarin Forms: How to set a list of items as the Expander Child?

$
0
0

I am using an Expander for showing units and chapters of a book. I am able to show the units as the Expander.Header, but the chapters under the unit is again a list. I tried like below but chapters are not able to view on UI.

XAML

<StackLayout BindableLayout.ItemsSource="{Binding  AllItems,Mode=TwoWay}">
    <BindableLayout.ItemTemplate>
        <DataTemplate>
            <Expander
                ExpandAnimationEasing="{x:Static Easing.CubicIn}"
                ExpandAnimationLength="500"
                CollapseAnimationEasing="{x:Static Easing.CubicOut}"
                CollapseAnimationLength="500">
                <Expander.Header>
                    <StackLayout
                        Orientation="Horizontal">

                        <Label 
                            Text="{Binding unit.title}"
                            TextColor="Black"
                            HorizontalOptions="Start" 
                            HorizontalTextAlignment="Start"
                            FontSize="18"
                            VerticalTextAlignment="Center"
                            VerticalOptions="CenterAndExpand">
                        </Label>
                    </StackLayout>
                </Expander.Header>
                <Expander.ContentTemplate>
                    <DataTemplate>
                        <StackLayout 
                            Orientation="Horizontal">

                            <Label
                                HorizontalOptions="Start"
                                Text="{Binding contentList.title}"
                                VerticalOptions="CenterAndExpand"
                                FontSize="16"
                                TextColor="Black">
                            </Label>
                        </StackLayout>
                    </DataTemplate>
                </Expander.ContentTemplate>
            </Expander>
        </DataTemplate>
    </BindableLayout.ItemTemplate>
</StackLayout>

My JSON Data format:

"bookContentList": [
        {
            "unit": {
                "title": "Unit 1: Revelation"
            },
            "contentList": [
                {
                    "title": "Unit 1: Preview",
                    "embedCode": "c1"
                },
                {
                    "title": "Chapter 1: God&#39;s Plan for all creation",
                    "embedCode": "c2"
                },
                {
                    "title": "Chapter 2: Made to be with god",
                    "embedCode": "c3"
                },
                {
                    "title": "Chapter 3: Signs of gods presence",
                    "embedCode": "c4"
                }
            ]
        },
        {
            "unit": {
                "title": "Unit 2: Trinity"
            },
            "contentList": [
                {
                    "title": "Unit 2: Preview",
                    "embedCode": "c5"
                },
                {
                    "title": "Chapter 4: The mystery of the trinity",
                    "embedCode": "c6"
                },
                {
                    "title": "Chapter 5: Prayer and Worship",
                    "embedCode": "c7"
                },
                {
                    "title": "Chapter 6: Life of Virtue",
                    "embedCode": "c8"
                }
            ]
        }
    ]

ViewModel

private List<BookContentList> _allItems;
public List<BookContentList> AllItems
{
    get
    { return _allItems; }
    set
    {
        _allItems = value;
        OnPropertyChanged("AllItems");
    }
}
//setting data
AllItems = bookDetails.bookContentList;

My problem is chapters under each unit is not showing on the UI. I have uploaded a sample project here for the easy reference.

Also, I need to know how to get the complete details of the selected chapter?

Xamarin forms broadcast reciever

$
0
0

Hi guys,
I have a problem with my app. As I have authorization (username/password), and when I login in the application, and click the Lock button on my phone, my app logs out. Now I want the same thing, when i put my app in the background, and THEN I click lock button (now nothing happens, when I go back, user is logged in). I found something with the broadcast receiver, but I'm not able to figure it out
`

         [BroadcastReceiver(Enabled = true)]

            [IntentFilter(new[] { Android.Content.Intent.ActionScreenOff })]

            public class MySampleBroadcastReceiver : BroadcastReceiver

            {

                public override void OnReceive(Context context, Intent intent)

                {

                    switch (intent.Action)

                    {

                        case Intent.ActionScreenOff:

                            //My method for loging out user
                            break;

                    }
                }
            }

`
I'm not sure how to call this broadcast receiver, when app is in background and I'm locking the phone.
I hope someone can help me :)

Viewing all 79144 articles
Browse latest View live


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