问题标签 [xamarin.forms]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
mono - Xamarin.Forms Picker 导致应用程序崩溃
我设置了以下代码。当我导航到视图时模拟器崩溃。我正在尝试在我的应用程序中添加一个选择器,以显示每周、半年和每年等工资表。
我将它添加到这样的视图中:
下面是我得到的堆栈跟踪:
单声道:堆栈跟踪:
单声道:在 <0xffffffff>
mono-rt: at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_int_int_bool (intptr,intptr,int,int,bool)
mono-rt:在 MonoTouch.UIKit.UIPickerView.Select (int,int,bool) [0x00010] 在 /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/UIPickerView.g.cs:185
mono-rt:在 Xamarin.Forms.Platform.iOS.PickerRenderer.UpdatePicker ()
mono-rt:在 Xamarin.Forms.Platform.iOS.PickerRenderer.OnModelSet (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.Platform.iOS.ViewRenderer.SetModel (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.Platform.iOS.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.Platform.iOS.ViewPackager.HandleChildAdded (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.EnumerableExtensions.ForEach (System.Collections.Generic.IEnumerable
1<T>,System.Action
1)mono-rt:在 Xamarin.Forms.Platform.iOS.ViewPackager.Load ()
mono-rt:在 Xamarin.Forms.Platform.iOS.ViewRenderer.SetUpEventHandlers (MonoTouch.UIKit.UIView)
mono-rt:在 Xamarin.Forms.Platform.iOS.ViewRenderer.OnModelSet (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.Platform.iOS.ViewRenderer.SetModel (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.Platform.iOS.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.Platform.iOS.ViewPackager.HandleChildAdded (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.EnumerableExtensions.ForEach (System.Collections.Generic.IEnumerable
1<T>,System.Action
1)mono-rt:在 Xamarin.Forms.Platform.iOS.ViewPackager.Load ()
mono-rt:在 Xamarin.Forms.Platform.iOS.ViewRenderer.SetUpEventHandlers (MonoTouch.UIKit.UIView)
mono-rt:在 Xamarin.Forms.Platform.iOS.ViewRenderer.OnModelSet (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.Platform.iOS.ViewRenderer.SetModel (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.Platform.iOS.RendererFactory.GetRenderer (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.Platform.iOS.ViewPackager.HandleChildAdded (Xamarin.Forms.VisualElement)
mono-rt:在 Xamarin.Forms.EnumerableExtensions.ForEach (System.Collections.Generic.IEnumerable
1<T>,System.Action
1)mono-rt:在 Xamarin.Forms.Platform.iOS.ViewPackager.Load ()
mono-rt:在 Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad ()
mono-rt: at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr)
单声道:在 <0xffffffff>
mono-rt: at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper (intptr,intptr)
mono-rt:在 /Developer/MonoTouch/Source/monotouch/src/build/compat/UIKit/UIViewController.g.cs:2232 中的 MonoTouch.UIKit.UIViewController.get_View () [0x00030]
mono-rt:在 Xamarin.Forms.Platform.iOS.NavigationRenderer/d__d.MoveNext ()
mono-rt:在 System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Startd__d> (Xamarin.Forms.Platform.iOS.NavigationRenderer/d__d&) [0x0001b] 在 /Developer/MonoTouch/Source/mono/mcs/class/corlib/System .Runtime.CompilerServices/AsyncTaskMethodBuilder_T.cs:107
mono-rt:在 Xamarin.Forms.Platform.iOS.NavigationRenderer.OnPushAsync (Xamarin.Forms.Page,bool)
mono-rt:在 Xamarin.Forms.Platform.iOS.NavigationRenderer.PushPageAsync (Xamarin.Forms.Page,bool)
mono-rt:在 Xamarin.Forms.Platform.iOS.NavigationRenderer.OnPushRequested (object,Xamarin.Forms.NavigationRequestedEventArgs)
mono-rt:在 Xamarin.Forms.NavigationPage/d__c.MoveNext ()
mono-rt:在 System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Startd__c> (Xamarin.Forms.NavigationPage/d__c&) [0x0001b] 在 /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.CompilerServices/AsyncTaskMethodBuilder .cs:107
mono-rt:在 Xamarin.Forms.NavigationPage.PushAsync (Xamarin.Forms.Page)
mono-rt:在 Xamarin.Forms.NavigationPage/NavigationImpl.OnPushAsync (Xamarin.Forms.Page)
mono-rt:在 Xamarin.Forms.NavigationProxy.PushAsync (Xamarin.Forms.Page)
mono-rt:在 Xamarin.Forms.NavigationProxy.OnPushAsync (Xamarin.Forms.Page)
mono-rt:在 Xamarin.Forms.NavigationProxy.PushAsync (Xamarin.Forms.Page)
mono-rt:在 /Users/Projects/FNBMortgageForms/FNBMortgageForms/Views/HomePage.cs:59 中的 FNBMortgageForms.Shared.HomePage.m__1 (object,System.EventArgs) [0x00010]
mono-rt:在 Xamarin.Forms.Button.SendClicked ()
mono-rt:在 Xamarin.Forms.Platform.iOS.ButtonRenderer/<>c__DisplayClass1.b__0 (object,System.EventArgs)
mono-rt: 在 MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00007] 在 /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:33
mono-rt: at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr)
单声道:在 <0xffffffff>
mono-rt: at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr)
mono-rt:在 MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] 在 /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
mono-rt:在 /Users/Projects/FNBMortgageForms/iOS/Main.cs:17 中的 FNBMortgageForms.iOS.Application.Main (string[]) [0x00008]
mono-rt: at (wrapper runtime-invoke) .runtime_invoke_void_object (object,intptr,intptr,intptr)
mono-rt:本机堆栈跟踪:
单声道:
mobile - Xamarin.Forms - 检测方向和调整页面
我想在构建页面时知道设备(Android、iOS 和 Windows Phone)的方向。该页面有一个带有 3 个列定义的网格,并且一旦方向更改为横向,就应该有 5 个列定义。
所以在这里我添加了 12 张图片来测试我的代码。该页面在纵向方向上看起来不错,并且如果设备处于横向方向,则列之间的空间很大。
我也在尝试使用依赖注入来检索信息。DependencyService 正在做他的工作,但我没有成功检索设备的方向......
android-emulator - Xamarin.Forms ListView,如何设置RowHeight?
Xamarin.FormsListView
中的 有一个RowHeight
属性,但似乎无论我将其设置为什么高度。
我使用 Visual Studio 2013,我拥有 Xamarin 的商业版许可证,我使用 Android 模拟器MonoForAndroid_API_15,我相信我拥有所涉及的所有内容的最新版本。到目前为止,我还不能运行 iOS 或 WinPhone 模拟器,所以我无法比较。这只是 Android 模拟器的问题还是设置RowHeight
属性不正确?
这是我继承的ContentPage
(注意我设置RowHeight
):
在App
:
这是视觉结果:
请注意,我的代码是Xamarin 使用的 TODO 示例的简化版本,您可以看到它们RowHeight
以与我相同的方式设置属性。
无论我设置什么,因为RowHeight
行具有相同的巨大高度。我能做些什么?
编辑 1:我计划本周升级到 Windows 8.1,然后可以在 WinPhone 上测试它的外观。要在工作中将 Mac 添加到网络,我首先需要一些权限。这就是为什么我到目前为止只使用 Android 模拟器。
编辑2:我尝试设置HasUnevenRows
为true,如此处所建议的,但这只会让它接受更长的条目,而不是改变行的高度(或字体),这对我来说太大了。
编辑3:我发布了一个解决方案/解决方法作为答案。至少我可以完全控制单元格的高度。但RowHeight
似乎作用不大。
xamarin.forms - Xamarin Forms ScrollView 上的 ScrollOrientation.Both
有没有人有任何建议允许 ScrollView 允许向任何方向滚动。
似乎只有水平和垂直 ScrollOrientation 但没有同时做这两个选项的选项。
我的最终目标是能够捏合、缩放和滚动任何方向。
xamarin.ios - Xamarin 表单选择器 - 自定义 UIPickerView
使用 Xamarin 表单,如何更改默认选择器视图以显示在 PopoverController 中?下面的代码抛出“无法从没有窗口的视图中呈现弹出框”。在 iOS 上。
mobile - Xamarin.Forms:有谁知道 Xamarin.Forms 中 WillEnterForeground 和 DidEnterBackground 的等价物是什么?
我正在将我在 Xamarin.iOS 中编写的应用程序重写为 Xamarin.Forms,并且我曾经在 DidEnterBackground 和 WillEnterForeground 上执行一些代码。现在我在 Xamarin.Forms 中找不到等效的方法。我在我的 App 类中尝试过 mainPage.Appearing 和 mainPage.Disappearing,但它们似乎与我想要实现的不同。任何人?
xamarin.forms - Xamarin.Forms:StackLayout 内的 ListView:如何设置高度?
在一个里面ContentPage
我有一个ListView
里面一个StackLayout
里面一个ScrollView
。在被调用时ListView
填充(ItemSource
设置),我可以看到该列表已填充在模拟器中。s 方向是和低于我有一个。ContentPage
OnAppearing
StackLayout
Vertical
ListView
Button
我的问题是,无论有多少元素ListView
,它的高度都是 53.33。我希望 的高度ListView
与其中项目的总高度相匹配。通过设置HeightRequest
我可以设置的高度ListView
我想要的任何东西,但由于我不知道里面项目的高度,ListView
结果通常是到它下面的按钮的距离不正确,因此看起来很丑。我试图同时设置VerticalOptions
theListView
和StackLayout
toStart
以及其他设置,但这不会改变 53.33 的高度(如果我尝试结合使用HeightRequest
,Start
结果是 HeightRequest 胜出)。
我该如何解决这个问题?
(请原谅交叉张贴(请原谅Xamarin 论坛)
mvvm - Xamarin Forms:如何切换 ViewModel?
从 MvvmCross (mvx) 切换到表单。使用 Mvx,在 ViewModel 代码中,我使用ShowViewModel<MainViewModel>()
切换。如何使用 Xamarin Forms 做到这一点?
注意:我不想在代码隐藏文件中添加任何代码。
navigation - Android 全球不支持 PushAsync,请使用 NavigationPage - Xamarin.Forms
Xamarin.Forms.ContentPage
我在连接到按钮单击事件中有以下方法
在以下代码行中Navigation.PushAsync(new HomePage());
,调试时出现以下异常:
Android 全球不支持 PushAsync,请使用 NavigationPage
如何使用Xamarin.Forms.NavigationPage
对象解决此问题?
xamarin.forms - Xamarin.Forms UserControl 使用 XAML 和自定义渲染器
已经有一些很好的例子来说明如何通过以下方式创建“自定义控件” -
- 从 View 或现有的内置控件派生一个类,然后为每个平台创建一个自定义渲染器。
- http://blog.xamarin.com/using-custom-controls-in-xamarin.forms-on-android/
- http://developer.xamarin.com/guides/cross-platform/xamarin-forms/custom-renderer/
我想创建一个“复合自定义控件或用户控件”,其中包含在 XAML 中定义的多个元素(在共享代码中),然后使用渲染器进行自定义(比如调整每个平台的样式)。
请问有人有这样做的例子吗?一个带有可绑定标签和输入框的视图的简单示例应该足以显示主要原理。
这是我到目前为止所拥有的 -
定义了一个 ContentView 来表示我们的用户控件布局和内容。
使用代码隐藏 -
为该 ContentView 添加一个 Android 自定义渲染器,我如何访问和自定义 ContentView 的本机部分/控件?
只是无法将这些部分组合在一起工作,ContentView 似乎在页面上渲染得很好,但无法弄清楚如何在 viewrenderer 中访问其 Child Native 控件。
也很高兴展示如何将 Binding 用于 Label 和 Entry Text 值。
我不想为用户控件的每个标签/条目等定义自定义渲染器。