我想在按下时删除按钮背景颜色,并且喜欢具有透明背景,因为我使用图像作为背景.
鼠标悬停时能够通过以下代码删除边框:
btn.BorderThickness = new Thickness(0,0,0,0);
btn.Padding = new Thickness(0, 0, 0, 0);
Run Code Online (Sandbox Code Playgroud)
并通过设置:
btn.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Transparent);
Run Code Online (Sandbox Code Playgroud)
但是我点击它时无法删除背景,它显示的是灰色背景.
任何建议将不胜感激.
我需要实现的是,在将屏幕从纵向更改为横向时向现有页面添加布局。我设法使用void OnSizeAllocated(double width, double height)检测方向变化。但我无法在此事件上添加布局。
我的示例 C# 代码是
public class MyLayoutView : ContentPage
{
StackLayout portraitcontent = null;
StackLayout landscapecontent = null;
StackLayout footer = null;
public MyLayoutView ()
{
portraitcontent = new StackLayout ();
landscapecontent = new StackLayout ();
footer = new StackLayout ();
this.Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);
this.BackgroundColor = Color.FromHex ("#ffffff");
this.Content = new StackLayout
{
Children =
{
portraitcontent ,
landscapecontent ,
footer
}
};
}
}
Run Code Online (Sandbox Code Playgroud)
OnSizeAllocated 方法
protected …
Run Code Online (Sandbox Code Playgroud) 将Xamarin Forms更新为1.3.1版本后,我收到以下错误.
也试过更新Xamarin.Forms.Labs to 1.2.1 pre2
,它也没有帮助.
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.NullReferenceException: Object reference not set to an instance of an object
[MonoDroid] at Xamarin.Forms.Platform.Android.FormsApplicationActivity.OnDestroy () <IL 0x0002d, 0x000d8>
[MonoDroid] at Xamarin.Forms.Labs.Droid.XFormsApplicationDroid.OnDestroy () [0x0001f] in c:\Users\rmarinho\Documents\GitHub\Xamarin-Forms-Labs\src\Xamarin.Forms.Labs\Xamarin.Forms.Labs.Droid\XFormsApp.cs:61
[MonoDroid] at Android.App.Activity.n_OnDestroy (intptr,intptr) [0x00009] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.20-series/ba9bbbdd/source/monodroid/src/Mono.Android/platforms/android-17/src/generated/Android.App.Activity.cs:2524
[MonoDroid] at (wrapper dynamic-method) object.e36a43a7-84b6-4476-8a62-6959a3b43e6a (intptr,intptr) <IL 0x00011, 0x0003b>
Run Code Online (Sandbox Code Playgroud)
有关如何解决此错误的任何帮助?
我一直在尝试用xamarin表单录制音频,没有直接的方法可以做到这一点所以我试图通过自定义渲染实现它,我已经从这里按照示例.
// AVAudioRecorder创作
//set up the NSObject Array of values that will be combined with the keys to make the NSDictionary
NSObject[] values = new NSObject[]
{
NSNumber.FromFloat (16000.0f), //Sample Rate
NSNumber.FromInt32 ((int)AudioToolbox.AudioFormatType.MPEG4AAC), //AVFormat
NSNumber.FromInt32 (1), //Channels
NSNumber.FromInt32 (16), //PCMBitDepth
NSNumber.FromBoolean (false), //IsBigEndianKey
NSNumber.FromBoolean (false) //IsFloatKey
};
//Set up the NSObject Array of keys that will be combined with the values to make the NSDictionary
NSObject[] keys = new NSObject[]
{
AVAudioSettings.AVSampleRateKey,
AVAudioSettings.AVFormatIDKey,
AVAudioSettings.AVNumberOfChannelsKey,
AVAudioSettings.AVLinearPCMBitDepthKey,
AVAudioSettings.AVLinearPCMIsBigEndianKey,
AVAudioSettings.AVLinearPCMIsFloatKey
}; …
Run Code Online (Sandbox Code Playgroud)