小编use*_*474的帖子

将数字四舍五入到货币格式的正好两位小数

我需要四舍五入到小数位数的货币.

Math.round(num*Math.pow(10,2))/Math.pow(10,2)
Run Code Online (Sandbox Code Playgroud)

Math.round(num*Math.pow(10,2))/Math.pow(10,2)
Run Code Online (Sandbox Code Playgroud)

工作,除了它削减任何尾随零关闭,所以我得到29.9而不是29.90.

围绕这个最好的方法是什么?

javascript currency rounding

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

Xamarin.Forms用相机拍摄照片显示错误的方向和后退按钮崩溃

我从这里使用Xamarin.Forms Camera示例 - https://github.com/XForms/Xamarin-Forms-Labs-Samples/tree/master/XF.Labs.CameraSample我可以选择或拍照.

private async Task SelectPicture()
{
    mediaPicker = DependencyService.Get<IMediaPicker>();
    imageSource = null;
        var mediaFile = await mediaPicker.SelectPhotoAsync(new CameraMediaStorageOptions
            {
                DefaultCamera = CameraDevice.Front,
                MaxPixelDimension = 400
            });
        imageSource = ImageSource.FromStream(() => mediaFile.Source);
        img.Source  = imageSource;

}


private async Task TakePicture()
{
    mediaPicker = DependencyService.Get<IMediaPicker>();
    imageSource = null;
        var mediaFile = await mediaPicker.TakePhotoAsync(new CameraMediaStorageOptions
            {
                DefaultCamera = CameraDevice.Front,
                MaxPixelDimension = 400
            });
        imageSource = ImageSource.FromStream(() => mediaFile.Source);
        img.Source  = imageSource;

}
Run Code Online (Sandbox Code Playgroud)

图像的代码很简单

    img = new Image
    {
        BackgroundColor …
Run Code Online (Sandbox Code Playgroud)

camera android xamarin.forms

7
推荐指数
1
解决办法
7277
查看次数

xamarin.Forms只滚动页面的一部分

我有一个页面,我想在顶部始终查看标题,按钮始终在底部的视图中.中间的内容是可滚动的.

我认为这可以通过以下方式轻松实现:

StackLayout outer = new StackLayout();

StackLayout inner = new StackLayout();//with all of the content added

ScrollView scroll = new ScrollView();


outer.Children.Add(headerLabel);//non-scrolling

scroll.Content = inner;

outer.Children.Add(scroll);      //scrolling

outer.Children.Add(button);     //non-scrolling
Run Code Online (Sandbox Code Playgroud)

headerLabel和按钮保持在正确位置,但内容向上滚动到页面顶部,在headerLabel的顶部(但在底部按钮的下方/下方).

我很肯定它工作正常,但我不记得改变了什么.

有没有人知道为什么会发生这种情况?

layout scrollview xamarin

5
推荐指数
1
解决办法
5326
查看次数

Xamarin.Forms实现了AndHud和BTProgressHud

任何人都可以指向一个Xamarin.forms示例,该示例使用AndHud for Android和BTProgressHud for iOS(或类似的东西)?

我知道这里有ACR-Xamarin-Forms示例https://github.com/aritchie/acr-xamarin-forms,但它太复杂了,完全超出了我的想象.

当然有一个更简单易懂的实现,但如果没有关于如何开始实现它的某种指导(对于C#和Xamarin新手)

提前致谢

c# android activity-indicator ios xamarin.forms

4
推荐指数
1
解决办法
2997
查看次数

Xamarin.Forms GridLayout

有人可以解释Xamarin.Forms中的GridLayout引用吗?

使用FormsGallery上的示例,这里也可以看到http://iosapi.xamarin.com/?link=T%3aXamarin.Forms.Grid(也有图像)我试图解决它,但我的试验和错误没有非常成功,非常耗时.

查看网格的第一行,代码如下

grid.Children.Add(new Label
   {
       Text = "Grid",
       Font = Font.BoldSystemFontOfSize(50),
       HorizontalOptions = LayoutOptions.Center
  }, 0, 3, 0, 1);
Run Code Online (Sandbox Code Playgroud)

它看起来好像第一个0表示X位置,3表示列跨度,下一个0表示y位置,一个表示行跨度.但是使用它作为参考并尝试添加其他行和列它不起作用.如果他们的样本包含一些评论会很棒,但是因为他们不能告诉我GridLayout引用如何工作?

干杯

grid layout xamarin xamarin.forms

4
推荐指数
1
解决办法
1万
查看次数

Xamarin.Android从ListView单击事件中获取对象属性

我是C#(几周)和Xamarin(大约一周)的新手.

我能够从教程"在Android上的ListView中显示实体集合"(//来自http://diptimayapatra.wordpress.com/2013/07/08/xamarin-display-entity-collection-in-listview)实现ListView适配器-in-android /)

我现在的问题是我不知道如何处理TextView文本上的click事件.

我的适配器的GetView代码是:

public override  View GetView(int position, View convertView, ViewGroup parent)
{
    var incident = incidents[position];
    View view = convertView;
    if(view == null)
    {
        view = context.LayoutInflater.Inflate(
            Resource.Layout.ListViewTemplate, null);
    }

    view.FindViewById<TextView>(Resource.Id.tvIncident).Text = 
        string.Format("{0}", incident.title);

    view.FindViewById<TextView>(Resource.Id.tvIncidentDescription).Text = 
        string.Format("{0}", incident.description);

    return view;
}
Run Code Online (Sandbox Code Playgroud)

我的事件对象代码是:

public class Incident
{
   public int id {get; set;}
   public string title {get; set;}
   public string description {get; set;}
   public double latitude {get; set;}
   public double longitude {get; set;}
}
Run Code Online (Sandbox Code Playgroud)

然后活动中的代码是 …

c# listview xamarin.android xamarin

3
推荐指数
1
解决办法
1万
查看次数

Switch Cell的代码中的Xamarin.Forms DataBinding

我有以下对象:

public class Notification : INotifyPropertyChanged
{
    private bool _trafficNot;
    public bool TrafficNot 
    {
        get { return _trafficNot; }
        set {
                if (value.Equals(_trafficNot))
                    return;
                _trafficNot = value;
                OnPropertyChanged();

            } 
    }

    private bool _newsNot;
    public bool NewsNot
    {
        get { return _newsNot; }
        set
        {
            if (value.Equals(_newsNot))
                return;
            _newsNot = value;
            OnPropertyChanged();
        }
    }

   public event PropertyChangedEventHandler PropertyChanged;

    void OnPropertyChanged([CallerMemberName]String propertyName=null)
    {
        var handler=PropertyChanged;
        if(handler != null)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

我从这样的对象获取数据://根据DB Notification notification = new Notification {中存储的内容设置通知对象 …

c# data-binding xamarin.forms

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