小编Jan*_*der的帖子

将元素添加到Zxing条形码Xaml内容页面,Xamarin.forms

我正在使用Zxing.Net.Mobile.Forms来显示条形码.我不确定如何在一个页面上添加其他元素和条形码.我已尝试在c#和xaml中添加它,但我的其他元素没有显示.我想在条形码和条形码上方的图片后添加标签.

Barcode.xaml.cs

public partial class BarCode : ContentPage
    {
        ZXingBarcodeImageView barcode;
        public BarCode()
        {
            InitializeComponent();

            barcode = new ZXingBarcodeImageView
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,         
                };

                barcode.BarcodeFormat = ZXing.BarcodeFormat.CODE_128;
                barcode.BarcodeOptions.Width = 300;
                barcode.BarcodeOptions.Height = 150;
                barcode.BarcodeOptions.Margin = 10;
                barcode.BarcodeValue = Helpers.Settings.CardNumber;


                Content = barcode;

            }   
    }
Run Code Online (Sandbox Code Playgroud)

Barcode.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="LoyaltyWorx.BarCode"
             BackgroundImage="NewBg.jpg">
    <ContentPage.Content>
        <StackLayout>
        </StackLayout>
    </ContentPage.Content>


</ContentPage>
Run Code Online (Sandbox Code Playgroud)

zxing xamarin xamarin.forms

2
推荐指数
1
解决办法
1058
查看次数

注销显示警告xamarin.forms

我一直在尝试允许用户使用DisplayAlert确认注销.如果他们点击"否",它应该保留在他们的个人资料页面中,否则他们应该被重定向回登录页面.我没有设法完成这项工作,如果我单击是或否,两个选项都保留在配置文件页面中

public async void LogoutBtn(object sender, EventArgs e)
{
    var answer = await DisplayAlert("Exit", "Do you wan't to exit the App?", "Yes", "No");
    if(answer.Equals("Yes"))
    {
        Settings.FirstName = string.Empty;
        Settings.LastName = string.Empty;
        Settings.Email = string.Empty;
        await Navigation.PushAsync(new MainPage());
    }
    else
    {
        App.Current.MainPage = new Profile();
    }
}
Run Code Online (Sandbox Code Playgroud)

xamarin xamarin.forms

2
推荐指数
1
解决办法
406
查看次数

标签 统计

xamarin ×2

xamarin.forms ×2

zxing ×1