我将它设置为下面的代码,但它没有用。
ProductList.Margin = 10 //Exception
答案 0 :(得分:0)
如果ProductList
是View
,您可以更改其填充和边距:
ProductList.Css.Padding = 10;
ProductList.Css.Margin = 20;
答案 1 :(得分:0)
或者,您可以使用提供流畅API的扩展方法(因为它们返回对象),如下所示:
Helpers <UpdateOverlayMessage> :Transmitting request to the server...(called from Apply) -2037862263
Helpers <UpdateOverlayMessage> :Processing recieved response...(called from Apply) -2037862263
Helpers <UpdateOverlayMessage> :Processing response...(called from Apply) -2037862263
Helpers <UpdateOverlayMessage> :Updating sign list in progress, may be take a while...(called from Apply) -2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
Helpers <UpdateProgressValue> (called from Apply)-2037862263
这些扩展方法也允许您设置特定的边。例如:
public class LoadingOverlay : UIView {
// control declarations
UIActivityIndicatorView activitySpinner;
UILabel loadingLabel;
UIProgressView progressView;
public LoadingOverlay (CGRect frame) : base (frame)
{
// configurable bits
BackgroundColor = UIColor.Black;
Alpha = 0.55f;
AutoresizingMask = UIViewAutoresizing.All;
nfloat labelHeight = 22;
nfloat labelWidth = Frame.Width - 20;
// derive the center x and y
nfloat centerX = Frame.Width / 2;
nfloat centerY = Frame.Height / 2;
// create the activity spinner, center it horizontall and put it 5 points above center x
activitySpinner = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge);
activitySpinner.Frame = new CGRect (
centerX - (activitySpinner.Frame.Width / 2) ,
centerY - activitySpinner.Frame.Height - 20 ,
activitySpinner.Frame.Width,
activitySpinner.Frame.Height);
activitySpinner.AutoresizingMask = UIViewAutoresizing.All;
AddSubview (activitySpinner);
activitySpinner.StartAnimating ();
// create and configure the "Loading Data" label
loadingLabel = new UILabel(new CGRect (
centerX - (labelWidth / 2),
centerY + 20 ,
labelWidth ,
labelHeight
));
loadingLabel.BackgroundColor = UIColor.Clear;
loadingLabel.TextColor = UIColor.White;
loadingLabel.Text = "Wait a moment...";
loadingLabel.TextAlignment = UITextAlignment.Center;
loadingLabel.AutoresizingMask = UIViewAutoresizing.All;
AddSubview (loadingLabel);
progressView = new UIProgressView();
progressView.Progress = 0.0f;
var screenParts = Frame.Width / 3;
progressView.Frame = new CGRect(new CGPoint(screenParts,loadingLabel.Frame.Y + loadingLabel.Frame.Height + 20), new CGSize(screenParts,40));
progressView.Hidden = true;
AddSubview(progressView);
}
/// <summary>
/// Fades out the control and then removes it from the super view
/// </summary>
public void Hide ()
{
progressView.Progress = 0.0f;
InvokeOnMainThread(() => {
UIView.Animate(
0.5, // duration
() => { Alpha = 0; },
() => { RemoveFromSuperview(); }
);
});
}
public void SetLoadingLabel(String text)
{
InvokeOnMainThread(() => {
loadingLabel.Text = text;
});
}
public void UpdateProgress(float progressValue){
if(progressView.Hidden){
progressView.Hidden = false;
}
if(progressValue > 1){
progressValue = 1;
}
InvokeOnMainThread(() => {
progressView.SetProgress(progressValue, true);
});
}
}