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

SfListView not detecting swipe image when using prism?

$
0
0

Trying to handle clicking on a image in the leftswipe area. Using prism as below..but tapping on a image does nothing and produces no error.

Any suggestion?

............................
<sync:SfListView.LeftSwipeTemplate> //syncfusion


<Grid.ColumnDefinitions>



</Grid.ColumnDefinitions>



<Image.GestureRecognizers> //NOT WORKING

</Image.GestureRecognizers>






                        </Grid>
                        <Grid
                            Grid.Column="2"
                            BackgroundColor="#009EDA"
                            HorizontalOptions="Fill"
                            VerticalOptions="Fill">
                            <Grid HorizontalOptions="Center" VerticalOptions="Center">
                                <Image
                                    Grid.Row="0"
                                    Grid.Column="0"
                                    BackgroundColor="Transparent"
                                    HeightRequest="35"
                                    Source="site.png"
                                    WidthRequest="35" />
                            </Grid>

                        </Grid>
                    </Grid>
                </DataTemplate>
            </sync:SfListView.LeftSwipeTemplate>

.................................

//VIEW MODEL
public DelegateCommand SelectFavCommand { get; set; }
public ClientsViewModel(INavigationService navigationService, IPageDialogService ipageserve, IEventAggregator ea)
{
_navigationService = navigationService;
SelectFavCommand = new DelegateCommand(SelectFavCommandHandler);
}

    private void SelectFavCommandHandler(object sender)
    {
           //NEVER REACHES HERE
    }

System.IO.FileNotFoundException Could not load assembly System.Drawing

$
0
0

Hello,

I meet this error in a Xamarin.forms project using WebView and local html base url:

Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
Nom de fichier : 'System.Drawing.dll'
à Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
à Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
à Xamarin.Android.Tasks.ResolveAssemblies.Execute() Almicantarat.Droid

I read that: System.IO.FileNotFoundException: Could not load assembly System.Web in Mono for Android

but I don't know which client's source code I should compile.

I read that: Could not load file or assembly 'System.Drawing, Version=4.0.0.0
but in my project, reference to System.Drawing is coming from mono.android which is a Xamarin component!

Should I compile mono.android myself ? where could I find it ? does Xamarin provide it ?

See my references attached.

Thanks

How to use 'speechrecognition' plugin?

$
0
0

Hi
I'm want to use 'speechrecognition" (https://github.com/aritchie/speechrecognition)
I know how to install it by asking the developer directly, but I can not use it.
How do I use 'Continuous Dictation'?
I just want to put the speech into the editor by just pressing the button.

Issue with Forms 2.4.0.280 on an android [No view found for id 0x1 (unknown) for fragment]

$
0
0

Hello,

After an update of xamarin.forms nuget to 2.4.0.280, I have an issue with an android

Here's stack trace:

09-29 06:50:25.610 E/mono (17500): Unhandled Exception:
09-29 06:50:25.610 E/mono (17500): Java.Lang.IllegalArgumentException: No view found for id 0x1 (unknown) for fragment FragmentContainer{1716c46c #0 id=0x1}
referenceTable GDEF length=670 1
referenceTable GSUB length=7202 1
referenceTable GPOS length=24560 1
09-29 06:50:25.610 E/mono (17500): --- End of managed Java.Lang.IllegalArgumentException stack trace ---
09-29 06:50:25.610 E/mono (17500): java.lang.IllegalArgumentException: No view found for id 0x1 (unknown) for fragment FragmentContainer{1716c46c #0 id=0x1}
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1334)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1569)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1636)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:758)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2201)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2155)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2064)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:379)
09-29 06:50:25.610 E/mono (17500): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:607)
09-29 06:50:25.610 E/mono (17500): at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
09-29 06:50:25.610 E/mono (17500): at md5a32ee3795e82798420962242b26c9524.MvxFormsAppCompatActivity.n_onStart(Native Method)
09-29 06:50:25.610 E/mono (17500): at md5a32ee3795e82798420962242b26c9524.MvxFormsAppCompatActivity.onStart(MvxFormsAppCompatActivity.java:43)
09-29 06:50:25.610 E/mono (17500): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
09-29 06:50:25.610 E/mono (17500): at android.app.Activity.performStart(Activity.java:5953)
09-29 06:50:25.610 E/mono (17500): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
09-29 06:50:25.610 E/mono (17500): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
09-29 06:50:25.610 E/mono (17500): at android.app.ActivityThread.access$800(ActivityThread.java:144)
09-29 06:50:25.610 E/mono (17500): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
09-29 06:50:25.610 E/mono (17500): at android.os.Handler.dispatchMessage(Handler.java:102)
09-29 06:50:25.610 E/mono (17500): at android.os.Looper.loop(Looper.java:135)
09-29 06:50:25.610 E/mono (17500): at android.app.ActivityThread.main(ActivityThread.java:5221)
09-29 06:50:25.610 E/mono (17500): at java.lang.reflect.Method.invoke(Native Method)
09-29 06:50:25.610 E/mono (17500): at java.lang.reflect.Method.invoke(Method.java:372)
09-29 06:50:25.610 E/mono (17500): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
09-29 06:50:25.610 E/mono (17500): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
09-29 06:50:25.610 E/mono (17500):

There is an example of the issue
https://github.com/JTOne123/XamFormsMvxTemplate/blob/master/MvxForms.sln

PS: If switch back to 2.3.4, everything will be ok

Android OpenGLView displays on simulators but not on physical devices

$
0
0

Hi all, I have a bit of code here that runs very well on iOS, and in the Android simulator (all is displayed properly). However, I have tried to run it on two different devices (Nexus 5, and SM-P900) both of which will not display the OpenGL render, rather just a black box.

Here is my OpenTK code that is put into the OnDisplay method

using System;
using OpenTK.Graphics.ES20;
using OpenTK.Graphics;
using OpenTK;
using Xamarin.Forms;
using CubeCrack.Shared;
using System.Reflection;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
#if __ANDROID__
using Android.Util;
#endif

[assembly: Dependency(typeof(GLEngineShared))]
namespace CubeCrack.Shared
{
    public class GLEngineShared : GLEngine
    {
        uint frameBuffer;
        uint indexBuffer;
        
        uint colorRenderBuffer;
        uint depthRenderBuffer;
        int positionSlot;
        int colorSlot;
        int projectionSlot;
        int modelViewSlot;
        int cubieViewSlot;

        int width_pixels, height_pixels;

        float rotate = 0.0f;
        static readonly float offset = 2.05f;

        public OpenGLView View { get; set; }
        public CubeViewModel ViewModel { get; set; }
        Matrix4 animationMatrix;

        public GLEngineShared () { }

        void SetupRenderBuffers(){
            #if __ANDROID__
            width_pixels = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, (float) View.Width, Xamarin.Forms.Forms.Context.Resources.DisplayMetrics);
            height_pixels = (int)TypedValue.ApplyDimension(ComplexUnitType.Dip, (float) View.Height, Xamarin.Forms.Forms.Context.Resources.DisplayMetrics);
            Debug.WriteLine("width: " + width_pixels + " height: " + height_pixels);
            #else
            width_pixels = (int)View.Width;
            height_pixels = (int)View.Height;
            #endif
            GL.GenRenderbuffers (1, out depthRenderBuffer);
            GL.BindRenderbuffer (RenderbufferTarget.Renderbuffer, depthRenderBuffer);
            GL.RenderbufferStorage (RenderbufferTarget.Renderbuffer, RenderbufferInternalFormat.DepthComponent16,
                width_pixels, height_pixels);
            
            GL.GenRenderbuffers (1, out colorRenderBuffer);
            GL.BindRenderbuffer (RenderbufferTarget.Renderbuffer, colorRenderBuffer);
            GL.RenderbufferStorage (RenderbufferTarget.Renderbuffer, RenderbufferInternalFormat.Rgba4,
                width_pixels, height_pixels);
        }

        void SetupFrameBuffer(){
            GL.GenFramebuffers (1, out frameBuffer);
            GL.BindFramebuffer (FramebufferTarget.Framebuffer, frameBuffer);
            GL.FramebufferRenderbuffer (FramebufferTarget.Framebuffer, FramebufferSlot.ColorAttachment0,
                RenderbufferTarget.Renderbuffer, colorRenderBuffer);
            GL.FramebufferRenderbuffer (FramebufferTarget.Framebuffer, FramebufferSlot.DepthAttachment,
                RenderbufferTarget.Renderbuffer, depthRenderBuffer);
        }

        int CompileShader(string shaderName, ShaderType shaderType){
            string prefix;
            #if __IOS__
            prefix = "CubeCrack.iOS.";
            #elif __ANDROID__
            prefix = "CubeCrack.Droid.";
            #endif
            var assembly = typeof(GLEngineShared).GetTypeInfo ().Assembly;
            Stream stream = assembly.GetManifestResourceStream (prefix + "Shaders." + shaderName + ".glsl");
            string shaderString;
            using (var reader = new StreamReader (stream)) {
                shaderString = reader.ReadToEnd ();
            }
            int shaderHandle = GL.CreateShader (shaderType);
            GL.ShaderSource (shaderHandle, shaderString);
            GL.CompileShader (shaderHandle);
            return shaderHandle;
        }

        void CompileShaders(){
            int vertexShader = CompileShader ("SimpleVertex", ShaderType.VertexShader);
            int fragmentShader = CompileShader ("SimpleFragment", ShaderType.FragmentShader);
            int programHandle = GL.CreateProgram ();
            GL.AttachShader (programHandle, vertexShader);
            GL.AttachShader (programHandle, fragmentShader);
            GL.LinkProgram (programHandle);
            GL.UseProgram (programHandle);

            positionSlot = GL.GetAttribLocation (programHandle, "Position");
            colorSlot = GL.GetAttribLocation (programHandle, "SourceColor");
            projectionSlot = GL.GetUniformLocation (programHandle, "Projection");
            modelViewSlot = GL.GetUniformLocation (programHandle, "Modelview");
            cubieViewSlot = GL.GetUniformLocation (programHandle, "CubieView");

            GL.EnableVertexAttribArray (positionSlot);
            GL.EnableVertexAttribArray (colorSlot);
        }

        void SetupVBOs(){
            uint vertexBuffer;
            GL.GenBuffers (1, out vertexBuffer);
            GL.BindBuffer (BufferTarget.ArrayBuffer, vertexBuffer);
            GL.BufferData (BufferTarget.ArrayBuffer, (IntPtr)(Vector3.SizeInBytes * CubeData.Verticies.Length), CubeData.Verticies, BufferUsage.StaticDraw);
            GL.VertexAttribPointer (positionSlot, 3, VertexAttribPointerType.Float, false, Vector3.SizeInBytes, 0);



//          GL.GenBuffers (1, out indexBuffer);
//          GL.BindBuffer (BufferTarget.ElementArrayBuffer, indexBuffer);
//          GL.BufferData (BufferTarget.ElementArrayBuffer, (IntPtr)(sizeof(byte) * CubeData.Indices.Length), CubeData.Indices, BufferUsage.StaticDraw);
        }

        #region GLEngine implementation

        public void Initialize ()
        {
//          GL.Viewport (0, 0, (int)View.Width, (int)View.Height);
            SetupRenderBuffers ();
            SetupFrameBuffer ();
            CompileShaders ();
            SetupVBOs ();
        }

        public void DrawCornerCubes(){
            for (int i = 0; i < 8; i++) {
                var colorData = new List ();
                var colors = ViewModel.GetCornerColors (i);
                foreach (var color in colors) {
                    colorData.Add (CubeData.GetVectorFromColor (color));
                }

                var ColorData = new Vector4[24];
                for(int j = 0; j < 24; j++){
                    ColorData[j] = new Vector4(0,0,0,1);
                }
                for(int j = 4; j <= 7; j++){
                    ColorData [j] = colorData [0];
                }
                for(int j = 16; j <= 19; j++){
                    ColorData [j] = colorData [1];
                }
                for (int j = 8; j <= 11; j++) {
                    ColorData [j] = colorData [2];
                }

                uint colorBuffer;
                GL.GenBuffers (1, out colorBuffer);
                GL.BindBuffer (BufferTarget.ArrayBuffer, colorBuffer);
                GL.BufferData (BufferTarget.ArrayBuffer, (IntPtr)(Vector4.SizeInBytes * ColorData.Length), ColorData, BufferUsage.StaticDraw);
                GL.VertexAttribPointer (colorSlot, 4, VertexAttribPointerType.Float, false, Vector4.SizeInBytes, 0);

                Matrix4 animateMatrix;
                if (ViewModel.IsCornerAnimating (i))
                    animateMatrix = animationMatrix;
                else
                    animateMatrix = Matrix4.Identity;
                
                Matrix4 rotationMatrix = Matrix4.CreateRotationX (CubeViewModel.CornerRotationTable [i][0]) *
                                         Matrix4.CreateRotationY (CubeViewModel.CornerRotationTable [i][1]) *
                                         Matrix4.CreateRotationZ (CubeViewModel.CornerRotationTable [i][2]);
                Matrix4 translationMatrix = Matrix4.CreateTranslation (offset * CubeViewModel.CornerTranslationTable [i] [0],
                                                offset * CubeViewModel.CornerTranslationTable [i] [1], offset * CubeViewModel.CornerTranslationTable [i] [2]);
                Matrix4[] cubieView = { rotationMatrix * translationMatrix * animateMatrix };
                GL.UniformMatrix4 (cubieViewSlot, false, ref cubieView [0]);
                GL.DrawElements(BeginMode.Triangles, CubeData.Indices.Length, DrawElementsType.UnsignedByte, CubeData.Indices);
                colorData.Clear ();

                GL.DeleteBuffers (1, ref colorBuffer);
            }
        }

        public void DrawEdgeCubes(){
            for (int i = 0; i < 12; i++) {
                var colorData = new List<Vector4> ();
                var colors = ViewModel.GetEdgeColors (i);
                foreach (var color in colors) {
                    colorData.Add (CubeData.GetVectorFromColor (color));
                }

                var ColorData = new Vector4[24];
                for(int j = 0; j < 24; j++){
                    ColorData[j] = new Vector4(0,0,0,1);
                }
                for(int j = 4; j 

The error I with the Nexus 5 is

[Adreno-EGLSUB] : Invalid native buffer. Failed to queueBuffer
[Adreno-EGLSUB] : native buffer is NULL

And over with my Samsung Note 12.2 (SM-P900)
I noticed this line, which I believe is relevant

[mali_winsys] new_window_surface returns 0x3000

Neither of the applications crash, but just display a black box where I should have OpenGL code rendering.

Any advice on how to debug or find the problem and solution would be much appreciated.

Setting a header of a grid in a listview

$
0
0

Hey, I am trying to add a header to my listview. My listview contents will be a grid, so the column sizes will change dynamically. I have tried using listview.header, but the size of the header column is not related to the grid so does not size appropriately.

I have also tried adding another row in the grid. The first one being the header. But as expected, this duplicates for each row of the listview. Is there an easy way to do this, or to say, this is first row in listview, so only display header on this row?

Here is my code

<ListView ItemsSource="{Binding Orders}" HorizontalOptions="Center">
          <ListView.Header>
              <StackLayout Orientation="Horizontal" BackgroundColor="Black">
                <Label Text="Product" />
                <Label Text="Quantity" />
              </StackLayout>
          </ListView.Header>
          <ListView.ItemTemplate>
            <DataTemplate>
              <ViewCell>
                <Grid Style="{StaticResource GridInListViewStyle}" HorizontalOptions="Center" >
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="75"/>
                  </Grid.ColumnDefinitions>
                  <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                  </Grid.RowDefinitions>
                  <Label  Text="Product" BackgroundColor="Green" Grid.Column="0" Grid.Row="0" />
                  <Label Text="Quantity" BackgroundColor="Green" Grid.Column="1" Grid.Row="0"/>
                  <StackLayout Orientation="Horizontal" Grid.Column="0" Grid.Row="1" Padding="10, 0, 0, 0">
                    <Label Text="{Binding ProductName}" VerticalOptions="Center" />
                  </StackLayout>
                  <Entry Keyboard="Numeric" Grid.Column="1" Grid.Row="1" VerticalOptions="Center"/>
                </Grid>
              </ViewCell>
            </DataTemplate>
          </ListView.ItemTemplate>
        </ListView>

Attached is current layout

Thanks

How to resolve the error _WebTryThreadLock(bool) in Xamarin forms IOS

$
0
0

Hi,
I am getting the below error in iPhone 10, other phone it is working fine.

I am trying to close the popup page has one webview and button, on button click I am showing an confirmation alert message on click ok I am trying to close the Popup page,
Used Rg.plugins.popup for thr popup page.

bool _WebTryThreadLock(bool), 0x60c0004001e0: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...

@BalakrishnanS

WCF communication problem for Android device only

$
0
0

Hi there
My app throws the exception
"SecureChannelFailure. The authentication or decryption is failed".
Strange enough, it is not working for Android only. The iOS device works fine with no errors at all.
What can be that makes it not working for Android?
Thanks.


Weird Pressed shadow in android after updating to XF 2.5

$
0
0

Hello
After upgrading to XF 2.5 I have a weird small shadow on every android button after pressing them.
https: //drive.google.com/open?id =1V3LMp5o1f8hwaPZL3jTA4b8jJToyq-5t
here is a video of what happens after I press a button.

here is the code of the button

                <Button HeightRequest="60"
                        x:Name="CameraButton"
                        Image="camera_cyan.png"
                        Clicked="OnCameraClicked" 
                        FontSize="Medium"
                        CornerRadius="5"
                        TextColor="{StaticResource Primary}"
                        BackgroundColor="{StaticResource PrimaryAlternate}"/>

Tizen on macOS

Getting IndexOutOfRangeException when I try to get the DependencyService for tabbed pages.

$
0
0

This is the code for the TabbedPage.xaml
`using RapidRate.Models;
using RapidRate.Services;
using RapidRate.ViewModels;
using System.Collections.Generic;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace RapidRate
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MyReviewsTabbedPage : TabbedPage
{
public MyReviewsTabbedPage()
{
InitializeComponent();

        BindingContext = new MyReviewsViewModel(
            DependencyService.Get<INavService>()
        );
    }

    MyReviewsViewModel _vm
    {
        get {
            return BindingContext as MyReviewsViewModel;
        }
    }

    protected override async void OnAppearing()
    {
        base.OnAppearing();
        if (_vm != null)
            await _vm.Init();
    }
}

}`

INavService.cs
`using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RapidRate.ViewModels;

namespace RapidRate.Services
{
public interface INavService
{
bool CanGoBack { get; }

    Task GoBack();

    Task NavigateTo<TVM>() where TVM : BaseViewModel;

    Task NavigateTo<TVM, TParameter>(TParameter parameter) where TVM : BaseViewModel;

    Task RemoveLastView();

    Task ClearBackStack();

    Task NavigateToUri(Uri uri);

    event PropertyChangedEventHandler CanGoBackChanged;
}

}
`

and here is the view model for the tabbed page:
`using RapidRate.Models;
using RapidRate.Services;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;

namespace RapidRate.ViewModels
{
class MyReviewsViewModel : BaseViewModel
{
public MyReviewsViewModel(INavService navService) : base(navService)
{
AvgScores = new ObservableCollection();
MyReviews = new ObservableCollection();
}

    private ObservableCollection<RapidRateReport> _avgScores;
    public ObservableCollection<RapidRateReport> AvgScores
    {
        get { return _avgScores; }
        set { _avgScores = value; OnPropertyChanged(); }
    }

    private ObservableCollection<PeopleRapidRate> _myReviews;
    public ObservableCollection<PeopleRapidRate> MyReviews
    {
        get { return _myReviews; }
        set { _myReviews = value; OnPropertyChanged(); }
    }

    public override async Task Init()
    {
        await LoadEntries();
    }

    async Task LoadEntries()
    {
        AvgScores.Clear();
        List<RapidRateReport> reviews = WebService.GetRapidRateAvgReport(App.CompanyID, App.PID);
        foreach(RapidRateReport review in reviews)
        {
            AvgScores.Add(review);
        }
    }
}

}`

Is there anything else you need?

How to add items to custom control

$
0
0

I would like to build a custom Frame control with an SKCanvasView as a background.

I already have a "SolidBox" control which works wonderfully.

Currently, I make a Grid, fill it with a SolidBox, then put my content inside.

I would like to do this the way the Frame control does.

Here is what I currently do:

<Grid HorizontalOptions="Center"
      VerticalOptions="Center">

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

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

    <controls:SolidBox Grid.Row="0" Grid.Column="0"
                       HorizontalOptions="FillAndExpand"
                       VerticalOptions="FillAndExpand"
                       LineColor="DarkBlue"
                       LineThickness="4"
                       CornerRadius="5"
                       InnerColor="White"/>

    <Grid Grid.Row="0" Grid.Column="0"
          HorizontalOptions="Center"
          VerticalOptions="Center"
          Margin="5">

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

        <!-- Add my content -->
        <Label Grid.Row="0" Text="Line 1"/>
        <Label Grid.Row="1" Text="Line 2"/>
        <Label Grid.Row="2" Text="Line 3"/>

    </Grid>

</Grid>

What I would like to do is create a control to simplify things

<controls:CustomFrame HorizontalOptions="FillAndExpand"
                      VerticalOptions="FillAndExpand"
                      LineColor="DarkBlue"
                      LineThickness="4"
                      CornerRadius="5"
                      InnerColor="White"/>

    <StackLayout Orientation="Vertical">

        <!-- Add my content -->
        <Label Grid.Row="0" Text="Line 1"/>
        <Label Grid.Row="1" Text="Line 2"/>
        <Label Grid.Row="2" Text="Line 3"/>

    </StackLayout>

</controls:CustomFrame>

But I don't know how to handle the children of the control in the xaml.cs ...
When the StackLayout is added in xaml, how do I handle that in my xaml.cs?

Java.Lang.IllegalArgumentException: No view found for id 0x1 (unknown) for fragment

$
0
0

In my project after updating all nugets I get the error; Java.Lang.IllegalArgumentException: No view found for id 0x1 (unknown) for fragment FragmentContainer{b5b55d0 #2 id=0x1}. How can I solve it? App opens but when I click navigate to a page which contains listview, I get this error.

Performance problem with scrollview

$
0
0

Hey guys!

I'm currently developping an application with xamarin in C# for ios and Android and I've come with performance issues.

I have 2 pages that are problematic but it may be for the same reason so to keep it simple I'll only use my first exemple.

So basically the page is only text, a couple paragraph and some images.

        <Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5">
            <Image Source="degrade_gris.png" Aspect="Fill"  />
        </Grid>

        <Grid Grid.Row="0" Grid.Column="2" x:Name="Menu">
            <Label x:Name="menu" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" TextColor="Black" FontSize="Large" FontAttributes="Bold"/>
            <ContentView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Grid.Row="0">
            </ContentView>
        </Grid>
        <Grid Grid.Row="0" Grid.Column="1" x:Name="bars">
            <Image Source="menu_icon.png"/>
            <ContentView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                <ContentView.GestureRecognizers>
                    <TapGestureRecognizer Tapped="OuvrirMenu"/>
                </ContentView.GestureRecognizers>
            </ContentView>
        </Grid>
        <Grid Grid.Row="0" Grid.Column="3">
            <Image Source="home.png" x:Name="home"/>
            <ContentView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                <ContentView.GestureRecognizers>
                    <TapGestureRecognizer Tapped="Retour"/>
                </ContentView.GestureRecognizers>
            </ContentView>
        </Grid>
        <ScrollView BackgroundColor="#484848" Grid.Row="1" Grid.ColumnSpan="5">
            <StackLayout Orientation="Vertical" BackgroundColor="#484848">
                <Image Source="CRPD_blanc.png" HeightRequest="100" Margin="0,15,0,0"/>
                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" Margin="15">first paragraph.</Label>
                <Image Source="icon_flag" HeightRequest="75" Margin="0,15,0,0"/>
                <Label HorizontalTextAlignment="Center" TextColor="#B1B1B1" FontSize="Large" FontAttributes="Bold">MANDAT</Label>
                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" Margin="15">another paragraph</Label>

                <Image Source="icon_story" HeightRequest="75" Margin="0,15,0,0"/>
                <Label HorizontalTextAlignment="Center" TextColor="#B1B1B1" FontSize="Large" FontAttributes="Bold">HISTORIQUE</Label>
                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" FontAttributes="Bold" Margin="15">1997, « LE DÉBUT »</Label>
                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" Margin="15">
                   another paragraph
                </Label>
                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" Margin="15">
                   another paragraph.
                </Label>
                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" Margin="15">
                    another paragraph
                </Label>
                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" Margin="15">
                    another paragraph
                </Label>

                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" FontAttributes="Bold" Margin="15">2007, 10IÈME ANNIVERSAIRE DU COMITÉ</Label>
                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" Margin="15">
                    another paragraph
                </Label>

                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" FontAttributes="Bold" Margin="15">2011, « POUR NE PAS PERDRE LE NORD »</Label>
                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" Margin="15">
                    another paragraph
                </Label>

                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" FontAttributes="Bold" Margin="15">2018, « BEST BRO »</Label>
                <Label HorizontalTextAlignment="Start" TextColor="#B1B1B1" Margin="15">
                    another paragraph
                </Label>

                <Image Source="icon_membres" HeightRequest="75" Margin="0,15,0,0"/>
                <Label HorizontalTextAlignment="Center" TextColor="#B1B1B1" FontSize="Large" FontAttributes="Bold">MEMBRES DU COMITÉ</Label>

                <Image Source="partenaire" Margin="15"/>

            </StackLayout>
        </ScrollView>

    </Grid>
</ContentPage.Content>

I use a grid with 2 row and 5 column,
first row is the header, (button,title,button)
second row is columnspan 5 and is a scrollview with all my text.

Why does this lag so badly?
What does xamarin do in the background? it is as if it calculate labels wrapping on each frame.
Is this the right way to do it?

My other page have stacklayouts in stacklayouts, is this a problem?

Thank you!

WebView read and set cookies.

$
0
0

Hi there,

I am new to xamarin forms but not to c#.
But still...

I have made a website wrapper and i want to read/set cookies from the webview.
But where do I start, i read something about making a custom renderer but how does that work and is this still up2date?


fixed with/mono font

$
0
0

I have been trying to draw a label in fixed with font. How is this done?

This does not work:

<Label Text="P1" FontFamily="Generic Monospace">

There must be some font that is available on both Android and iOS right?

Add a data into the Listview

$
0
0

Hi,

I use navigation page to navigate from page A to page B.
Page B only contains a Entry When a users Enter a data in the Entry. The page is poped.
Now when popping page B, I would like for page A to receive the value selected in Page B and i want to show the data into the listview
how can i do that. Please let me know if anyone have this solution for this problem

In short:
1) NavigationPage
2) Navigate from page A to page B
3) Get the Value from user
4) return selected value from page B to page A
5)Value Display into listview

Thanks in advance!

Convert base64 string to PDF file

$
0
0

Hi there.

I have the scenario is below:

  • A base 64 string (i catch from a webservice) that represents a PDF file
  • I need convert that string to a PDF file, and open with the default PDF reader
  • Must work for Android, iOS and UWP

Someone have a idea that how i do it, keywords or where to start?

Thanks.

Convert docX to PDF free

$
0
0

I'm trying to figure out how to convert a docX file that was downloaded as a byte stream and written to a file into a PDF so that I can open it using the PDFViewPage. I'd rather not pay for any packages. I tried Sautinsoft pdfmetamorphosis, but couldn't get that to work. All of their examples were for various Windows versions, and when attempting to compile I would get this error: System.IO.FileNotFoundException: Could not load assembly 'PdfMetamorphosis, Version=6.8.4.10, Culture=neutral, PublicKeyToken=f77041e5caa5fc2f'. Perhaps it doesn't exist in the Mono for Android profile? File name: 'PdfMetamorphosis.dll' Is this package meant for mobile?

Here's my code:

    async void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
    {
        Publication p = (Publication)e.SelectedItem;
        Debug.WriteLine(p);
        if (p.folderID.Equals("-1"))
        {
            using (Stream respStream = await post(p.docNum))
            {
                string ext = p.appextension.ToLower();
                byte[] buffer = new byte[respStream.Length];
                respStream.Read(buffer, 0, buffer.Length);
                string path = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/downloadedFile." + ext;
                File.WriteAllBytes(path, buffer);
                switch (ext)
                {
                    case "pdf":
                        await Navigation.PushAsync(new PDFViewPage(path));
                        break;
                    case "docx":

                        //Convert docX at "path" to PDF here, then call "await Navigation.PushAsync(new PDFViewPage(path));"

                        //SautinSoft.PdfMetamorphosis converter = new SautinSoft.PdfMetamorphosis();
                        //string pdfPath = Path.ChangeExtension(path, ".pdf");
                        //converter.DocxToPdfConvertFile(path, pdfPath);
                        //await Navigation.PushAsync(new PDFViewPage(pdfPath));

                        await DisplayAlert("Error", ".docx files are not supported at this time", "Return");
                        break;
                    default:
                        Debug.WriteLine("wasn't pdf");
                        Debug.WriteLine("was a ." + ext);
                        break;
                }


            }
        }
        else
        {
            await Navigation.PushAsync(new PublicationsPage(p.folderID));
        }
    }

    private async Task<Stream> post(string id)
    {
        Dictionary<string, string> dir = new Dictionary<string, string>();
        dir.Add("LoginID", App.user.login_id);
        dir.Add("docID", id);
        var jsonReq = JsonConvert.SerializeObject(dir);
        Debug.WriteLine("req: " + (String)jsonReq);
        var content = new StringContent(jsonReq, Encoding.UTF8, "application/json");
        var response = await client.PostAsync(url, content);
        var responseString = await response.Content.ReadAsStreamAsync();
        return responseString;
    }
}

Font loading error based on platform

$
0
0

Hi,

I'm trying to follow the same code as found under Working With Fonts. Original:

label.Font = Device.OnPlatform(
iOS: Font.OfSize ("MarkerFelt-Thin", NamedSize.Medium),
Android: Font.OfSize ("Droid Sans Mono", NamedSize.Medium),
WinPhone: Font.OfSize ("Comic Sans MS", NamedSize.Medium)
);

My version:

public static class StyleGuide
{
public static Font SideMenuFont = Device.OnPlatform( iOS: Font.OfSize("Helvetica", 24));
}

The error I receive:

Error CS1502: The best overloaded method match for Xamarin.Forms.Device.OnPlatform(System.Action, System.Action, System.Action, System.Action)' has some invalid arguments (CS1502) Error CS1503: Argument #1' cannot convert Xamarin.Forms.Font' expression to type System.Action' (CS1503) (trkr)

I fail to see any difference compared to the guide here. Any ideas?

Viewing all 81910 articles
Browse latest View live


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