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

ToolbarItem Icon Property - Blue Box instead of Icon Image in NavigationBar

$
0
0

Hello,

can anyone post an example of the toolbar item icon implementation?
I only see a clickable blue box with the dimensions of my icon in the navigation bar when I implement it in XAML or in CodeBehind like shown below.

<ContentPage>
<ToolbarItem Name="Icon" Icon="filter.png" Order="Default"/>
</ContentPage>

When I set the Order property to "Secondary" then it works and I see the icon and the text.. but it is in a second bar then and not in the main navigation bar. Only showing a text without an icon in the navigation bar works too.

Thank You


Lorem Ipsum when a new archive is made

$
0
0

Whenever i create a new archive my app i get lorem ipsum text in comment section. when i close visual studio for mac ,then it is gone.

  1. Why i am getting lorum ipsum text on first time?
  2. Is there a place to provide something meaningful for each build in this comment section?
  3. is it a bug in vs that on first time i am getting some random text while after restart it is gone?

Issue while opening Xamarin form from BroadcastReciever class

$
0
0

This is for tracking incoming and outgoing phone calls. I am pushing a Xamarin form in the application Navigation stack from BroadcastReciever class using following code:

var phoneAddPage = new SomePage();
Xamarin.Forms.Application.Current.MainPage = new NavigationPage(phoneAddPage);

The page is getting pushed properly as expected. Issue is the page is overlapped by Splash Screen when application is opened. The form is functioning properly, overlap is the only issue.

UWP app breaks when the code execution comes to displayalert line

$
0
0

I am using displayalert in my project and it is working fine on android and ios devices. But for the UWP part it is not working in some pages. When the code execution comes to displayalert line the UWP app breaks and redirecting to App.g.i.cs. Code control comes to the following if block.

#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
        UnhandledException += (sender, e) =>
        {
            if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
        };
#endif

If I mouse over the e showing {Windows.UI.Xaml.UnhandledExceptionEventArgs}

I am using the following code for display alert:

await DisplayAlert("Alert", "A verification code has been sent to your email.", "OK");

If I changed the above lines like below, no issue will come.

Device.BeginInvokeOnMainThread(async () => 
{
    await DisplayAlert("Alert", "A verification code has been sent to your email.", "OK");
});

Is there any solution to this issue without adding Device.BeginInvokeOnMainThread? And what is the reason behind this issue?

The immovable problem with Xamarin.iOS

$
0
0

Good day to you people , i'm trying to deploy my app on to a iphone device and i get the following error :

"/Users/systemadmin/Library/Caches/Xamarin/mtbs/builds/POD.iOS/07c34a292fa4873ef8290af52bfd88ba/bin/iPhone/Debug/POD.iOS.app: errSecInternalComponentPOD.iOS"

i have tried everything that google could offer me and nothing worked , could some help me out with some pointers ?

My app command bar changed its color for no good reason

$
0
0

A strange thing happened to my application. The main window command bar (the one with minimize and maximize buttons) from common gray became black. The buttons stayed gray. I don't think I did anything to cause this.
Could you please give me any idea what did this and how to change this back?

How can I make my navigation bar text bold?

$
0
0

Dear experts,

I have a Master-Detail architecture, and I need to make the detail page's title text of the navigation bar bold. How can I do that the simplest way?

Here is some of my code:

        private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            var item = e.SelectedItem as MainMDPageMenuItem;
            if (item == null)
                return;

            item.ItemBorderColor = Color.Red; // Make a red frame around the selected item
            if (PreviouslySelectedItem != null)
            {
                PreviouslySelectedItem.ItemBorderColor = Color.FromHex("#00a8d5"); // Return the original color to the previously selected (now deselected) item
            }

            var page = (Page)Activator.CreateInstance(item.TargetType);
            page.Title = item.Title; // THIS IS THE TITLE I AM TALKING ABOUT

            Detail = new NavigationPage(page);
            IsPresented = false;

            MasterPage.ListView.SelectedItem = null;

            PreviouslySelectedItem = item;
        }

Thanks.

How to change the visiblity of selected image in listview xamarin forms?

$
0
0

Need to change the image visibility to true when clicking the item in the listview.Please help
`

            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="auto" />
                            </Grid.ColumnDefinitions>
                            <Label
                                Margin="20,0,0,0"
                                Style="{StaticResource BasicFontLabelMedium}"
                                Text="{Binding firstName}"
                                VerticalOptions="Center" />
                        **    <Image
                                HeightRequest="30"
                                HorizontalOptions="End"
                                IsVisible="{Binding Selected}"
                                Source="tick_orange"
                                VerticalOptions="End"
                                WidthRequest="30" />**
                        </Grid>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>`

Touch and hold button to repeat action

$
0
0

Hi,

I have a requirement to develop a control similar to the Number Picker in Xamarin forms (where you have a + and - button to set a value). I need to show a + and - button and a label showing the current value. I need to be able to hold the button down to increment the number - not tap on the button over and over. I only really need it for Android.

I have created a custom control extending from View with a bindable property for CurrentValue. I have then created a custom renderer which returns a relative layout with two buttons and a label. I have called SetOnTouchListener and created a function to SetOnTouchListener which increments the number when either of the buttons are pressed. This all works fine when i press the button once -> the OnElementPropertyChanged event is fired and the UI updates. I have tried creating a timer on the ondown Motion and updating the "SelectedValue" of the control on an interval while the button remains down - but the OnElementPropertyChanged doesent fire in this case.

Is there something i am missing here? Below is what my OnTouchListener looks like. Is it because the timer cannot update the main thread? I put a breakpoint on my customControl binded property and i can see the setter for it is being called - but the value dosent change.

Please help!

public class MyTouchListener : Java.Lang.Object, Android.Views.View.IOnTouchListener
{
CustomControl myCustomControl;
CustomControlRenderer myCustomControlRenderer;
Android.Widget.RelativeLayout myRelativeLayout;

        public static readonly MyTouchListener Instance = new MyTouchListener();

        private int _normalInterval;
        private int _initialInterval;
        private Timer _timer;
        private bool _isLongPress = false;

        public MyTouchListener()
        {
            _initialInterval = 500;
            _normalInterval = 1000;
            _timer = new Timer(_initialInterval);
            _timer.Enabled = false;
            _timer.Elapsed += HandleTimerElapsed;
        }

        void HandleTimerElapsed(object sender, ElapsedEventArgs e)
        {
            _isLongPress = true;
            InvokeClickListener();
            _timer.Interval = _normalInterval;
        }

        private void InvokeInitialClickListener()
        {
            myCustomControl.SelectedValue++;
        }

        private void InvokeClickListener()
        {
            myCustomControl.SelectedValue++;
        }

        private void InvokeCancelListener()
        {

        }

        public bool OnTouch(Android.Views.View v, Android.Views.MotionEvent e)
        {
            var renderer = v.Tag as CustomControlRenderer;
            if (renderer == null)
                return false;

            myRelativeLayout= renderer.Control;
            myCustomControl= renderer.Element;

            if (v == renderer._upButton)
                switch (e.Action)
                {
                    case MotionEventActions.Down:
                        _timer.Enabled = true;
                        _timer.Start();
                        _isLongPress = false;
                        InvokeInitialClickListener();
                        return true;
                    case MotionEventActions.Up:
                    case MotionEventActions.Cancel:
                        _timer.Stop();
                        InvokeCancelListener();
                        return true;
                }
            return false;
        }
    }

Style.Triggers TargetType="Button" Property="IsEnabled"

$
0
0

Hello,

I wanted to give a new try to Triggers to avoid using converters / VisualState / CustomRenderer.

I got a ListView filled with data which contains several buttons. Those buttons have their IsEnabled property binded and they use a style which use a Trigger to change the TextColor / Opacity / BackgroundColor to show to user that a button is either available or not.

It doesn't seems to work as I expect.

Here is the style :
<Style x:Key="ContextualCellButtonStyle" TargetType="Button">
<Style.Triggers>
<Trigger TargetType="Button" Property="IsEnabled" Value="False">
<Setter Property="Text" Value="IsEnabled=False" />
<Setter Property="TextColor" Value="Green" />
<Setter Property="BackgroundColor" Value="Red" />
</Trigger>
<Trigger TargetType="Button" Property="IsEnabled" Value="True">
<Setter Property="Text" Value="IsEnabled=True" />
<Setter Property="TextColor" Value="Red" />
<Setter Property="BackgroundColor" Value="Green" />
</Trigger>
</Style.Triggers>
</Style>

(The values used are not the final one, it's just to debug)
As you can see, when a button is enabled, the text should be IsEnabled=True with a green background and red foreground.
If the button is not enabled, the text should be IsEnabled=False with a red background and green foreground.

In my design time model, I've set the first item to enabled and the second one to disabled :

And in my XAML, I have this :

Here is the result I got :

You can see that when the IsEnabled=False, it uses the trigger IsEnabled=True and when the IsEnabled is set to true, I don't have the style I want too.

I guess the Triggers work when the IsEnabled property changes at runtime but I'm not sure. If it is the case, what do you recommend ? A custom control ? A custom renderer ?
I would like to avoid VisualState because I'd like to use MVVM without code behind for this stuff.

I have already written some custom renderer like this but I thought Trigger would be better in this case so I won't have to create a custom control and a custom renderer :

Any help or suggestion is welcomed.
Thanks for reading so far !

Iphone device is not showing in debug list in project.

$
0
0

Hello,
I am creating an app for ios and android with help of xamarin.forms. When I am connecting my iphone device with my mac system for debugging the code it is not showing in the debug list. There is still showing Ios device. But if I open any other project of xamarin.forms Iphone option is showing in the debug list. I don't know why it is not showing only in one project. Is there any setting to enable the iphone device for project? Or any other way to manage iphone device with project?

Messaging Center called twice in xamarin forms

$
0
0
MessagingCenter.Subscribe<string>(this, "LocationName", (value) =>
                {
                    FullPathName.Text = value;
                });

While I set a break point and notice that This MessagingCenter.Subscribe called twice.
How to solve this?

How can i download the pdf file with out opening the browser (With out using Device.OpenUri(pdfUr)

$
0
0

i need it like abackgroud proccess in my context it open the browser directly and ask me to download it but i need
to download it without asking the user . how can i remove the redirect proccess from the app to the browser and complete the process in the app.

thank you in advance.

How do I PopModalAsync by using the keyboard escape key?

$
0
0

I can't seem to find any good keydown event sample code that works for this in Xamarin Forms.

Please help! Thanks!

Show two pages side by side or as seperate pages

$
0
0

Hello,

I have two pages (a master and a detail page) that I want to show in my Xamarin.Forms app. The layout can be compared the UWP Mail app: The master page contains the list of all messages and the detail page shows one e-mail message. When the width of the app is small (e.g. phone), only one page is shown at a given time. When the users wants to read the email message (= visit the details page), the list of messages disappears and only the email message is shown (= navigates from master page to detail page). When the width of the app is sufficiently large (e.g. tablet in landscape mode), the list of email messages is shown on the left and the selected message is displayed on the right (= master and detail page are shown side by side).

How can I recreate such a behavior for my app? My master page is a list view from which I can navigate to the detail page, but I also want to show these two pages side by side when the app is wide enough.

My details "page" does not have to be a XAML page, I could also use e.g. ContentView if this is easier. However, thus far I was unable to create the layout I described.

Regards,
Philipp


XAML control 'does not exist in the current context'

$
0
0

I'm getting an intermittent error where my XAML codebehind complains that a control 'does not exist in the current context'.

This is my .xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyApp_Mobile.IncidentReport"
             Title="Report Incidents">
  <StackLayout Spacing="5" x:Name="layoutIncident">
    <Label Text="Incident Type:" VerticalOptions="Center" HorizontalOptions="StartAndExpand" />
    <Picker x:Name="IncidentTypePicker1" Title="Incident Type" HorizontalOptions="FillAndExpand">
      <Picker.Items>
        <x:String>Theft</x:String>
        <x:String>Fire</x:String>
        <x:String>Accident</x:String>
      </Picker.Items>
    </Picker>
    <Label Text="Incident Description:" VerticalOptions="Center" HorizontalOptions="StartAndExpand" />
    <Editor x:Name="IncidentDescription" WidthRequest="400" HeightRequest="200" />
    <Button Text="Submit" Clicked="OnButtonClicked" />
    <Label x:Name="lblMessage" Text="" VerticalOptions="Center" HorizontalOptions="StartAndExpand" />
  </StackLayout>
</ContentPage>

And this is my .xaml.cs:

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

using Xamarin.Forms;

namespace MyApp_Mobile
{
    public partial class IncidentReport : ContentPage
    {
        int count = 0;

        public IncidentReport()
        {
            InitializeComponent();
        }

        public void OnButtonClicked(object sender, EventArgs args)
        {
            lblMessage.Text = IncidentTypePicker1.SelectedIndex.ToString() + " " + IncidentDescription.Text;

            count++;
            ((Button)sender).Text =
                String.Format("{0} click{1}!", count, count == 1 ? "" : "s");
        }
    }
}

The IDE (Visual Studio 2013) sometimes complains that IncidentTypePicker1 and IncidentDescription do not exist, and sometimes it does not complain and I am able to Build and Deploy the app. Is there any reason for this intermittent error?

Build Specific UI

$
0
0

hi ,
Is it possible to build this specific UI on xamarin forms ? binding from an api !

x:Array of OnPlatform

$
0
0

Is it would works?

      <x:Array Type="{x:Type x:String}">
       <OnPlatform x:TypeArguments="x:String">
         <On Platform="Android, iOS">My string value for these platforms</On>
        </OnPlatform>
      </x:Array>

because I'm gettting the following error:

{System.InvalidCastException
  at (wrapper managed-to-native) System.Array.SetValueImpl(System.Array,object,int)
  at System.Array.SetValue (System.Object value, System.Int32 index) [0x00057] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 
  at System.Array.System.Collections.IList.set_Item (System.Int32 index, System.Object value) [0x00000] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 
  at Xamarin.Forms.Xaml.ArrayExtension.ProvideValue (System.IServiceProvider serviceProvider) [0x0003e] in D:\a\1\s\Xamarin.Forms.Xaml\MarkupExtensions\ArrayExtension.cs:30 
  at Xamarin.Forms.Xaml.ArrayExtension.Xamarin.Forms.Xaml.IMarkupExtension.ProvideValue (System.IServiceProvider serviceProvider) [0x00000] in D:\a\1\s\Xamarin.Forms.Xaml\MarkupExtensions\ArrayExtension.cs:37 
  at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, Xamarin.Forms.Xaml.INode parentNode) [0x00341] in D:\a\1\s\Xamarin.Forms.Xaml\CreateValuesVisitor.cs:104 
  at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x000ac] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:149 
  at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00044] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:143 
  at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00079] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:145 
  at Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00044] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:200 
  at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydrationContext visitorContext) [0x00054] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:139 
  at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml) [0x00058] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:87 
  at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (TXaml view, System.String xaml) 

Online Xamarin.Forms Layout Editor

$
0
0

Hey all!

I've been searching for an online XAML editor for Xamarin Forms that I can easily and quickly mock things up or just practice basics for layout designs without having to run Visual Studio, wait for my projec to build, run my emulator, etc..

I finally found one in the samples pages of the Ooui Library (lets you build xaml websites using Xamarin Forms):

https://s3.amazonaws.com/praeclarum.org/wasm/index.html

PROS:
1. It just works
2. It is free

CONS:
1. Currently uses Xamarin.Forms 2.5 so I was unable to mockup anything with FlexLayout (introduced in Xamarin.Forms 3.0)
2. Unable to get images to work

Again, the primary upside of this is going to be people who are not overly familiar with XAML and are looking to get a feel for layouts (screenshot from the website below).

Stringformat issues with dates and times... is this a xamarin bug??

$
0
0

Hi all,

I asked a question on this yesterday and had to give up... but before I did I did a search of this forum and found these two links..
As stated before... I am trying to format a llistview in xamerin that has more than one column of data.. to of the values are dates..
My issue is that one column shows a date and then 00:00:00 for time.. I don't want the time in this column ... and I have another column that I want to display the date and time but I don't want it to display the letter T.

Also something that I did not type in the question yesterday is that I need the column labeled..

So reading over these to post.. it appears that xamarin can do this this at all... is this true.

My code

                            <Label  Text="{Binding LAST_X_UPDATE, StringFormat='Date Updated = {0:MMMM d, yyyy HH:mm}'}"/>
                            this yields Date Updated 2018-12-12T22:12:00

Is this another xamerin bug?? Thanks again!
...

https://forums.xamarin.com/discussion/25666/using-stringformat-in-xaml-on-a-binding

https://forums.xamarin.com/discussion/18170/using-stringformat-in-binding-in-xaml

Viewing all 91519 articles
Browse latest View live


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