gpt4 book ai didi

c# - 使用 MonoTouch.Dialog 根据 RadioElement 的值显示多个 RootElement

转载 作者:太空宇宙 更新时间:2023-11-03 13:54:09 25 4
gpt4 key购买 nike

我一直在上下搜索有关如何执行此操作的信息:

我需要根据 RadioGroup 的值创建多个 RootElement,我不太确定如何或在何处编写它。

理想情况下,它会创建一个新的 RootElement (ColorsRoot) 并将其命名为“Color1”、“Color2”等。

这是我到目前为止所得到的。

    public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
// create a new window instance based on the screen size
window = new UIWindow (UIScreen.MainScreen.Bounds);
int i = 1;
RootElement ColumnRoot;
RootElement ColorsRoot = new RootElement ("Color" + i, new RadioGroup ("color" + i, 0)){
new Section(){
new RadioElement("Red", "color"+i),
new RadioElement("Light red", "color"+i),
new RadioElement("Dark red", "color"+i),
new RadioElement("Green", "color"+i),
new RadioElement("Light green", "color"+i),
new RadioElement("Dark green", "color"+i),
new RadioElement("Blue", "color"+i),
new RadioElement("Light blue", "color"+i),
new RadioElement("Dark blue", "color"+i),
}
};
EntryElement NameEntry;
BooleanElement OrientationBool;

var rootView = new RootElement("TouchBow"){
new Section(){
new RootElement("New rainbow"){
new Section("New rainbow"){
(NameEntry = new EntryElement("Name", "Enter a name", "")),
(ColumnRoot = new RootElement("Columns", new RadioGroup("columns",1)){
new Section(){
new RadioElement("3", "columns"),
new RadioElement("5", "columns"),
new RadioElement("9", "columns")
}
}),
//MAGIC COLOR IS HAPPENING RIGHT HERE?!
new RootElement("Colors"){
new Section(){
(ColorsRoot),
(ColorsRoot)
}
},
(OrientationBool = new BooleanElement("Horizontal", false)),
},
new Section(){
new StringElement("Save rainbow", delegate{
Console.WriteLine ("Name.Value: "
+ NameEntry.Value +
". ColumnRoot.RadioSelected: "
+ ColumnRoot.RadioSelected +
". Color: "
+ ColorsRoot.RadioSelected +
". Orientation: "
+ OrientationBool.Value);
}),
new StringElement("View rainbow",
() => { new UIAlertView("Tapped", "String Element Tapped", null, "ok", null).Show();
})
}
},
new StringElement("Load rainbow", delegate{

Console.WriteLine ("Name.Value: " + NameEntry.Value + ". ColumnRoot.RadioSelected: " + ColumnRoot.RadioSelected);
})
}
};

// If you have defined a view, add it here:
// window.AddSubview (navigationController.View);
var dvc = new DialogViewController(rootView);
var nav = new UINavigationController(dvc);
window.RootViewController = nav;
// make the window visible
window.MakeKeyAndVisible ();

return true;
}

最佳答案

请记住,您可以保存对层次结构各个部分的引用,并且可以动态添加和删除元素。

关于c# - 使用 MonoTouch.Dialog 根据 RadioElement 的值显示多个 RootElement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12855099/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com