3

class Fahrzeug

    {
        [Entry ("Typ")]
        public string typ;
        [Entry ("Name")]
        public string name;
        [RadioSelection("ListOfString")]
        public int selected=0;
        public IList<string> ListOfString;


    }
    public override void ViewWillAppear (bool animated)
    {
        base.ViewWillAppear (animated);
        Fahrzeug x = new Fahrzeug();
        x.typ="Neuwagen";
        x.name="BMW X3";
        x.ListOfString=new List<string>();
        x.ListOfString.Add("asdf");
        x.ListOfString.Add("bsdf");
    var bc= new BindingContext(null,x,"asdf");
        var dv = new MonoTouch.Dialog.DialogViewController(bc.Root,true);
        dv.WantsFullScreenLayout=false;
        dv.View.BackgroundColor=UIColor.DarkGray;


    this.startview.AddSubview(dv.View);

Hello, i have got the code above. startview is not fullscreen, there is a navbar above, the normal dv is also beyond the navbar, but when i click onto the ILISt to change the value, the ILIST is fullscreen, so i cannot get back,...important is also, that the actual is an UIView, i want this in an uiview,..and i want to use the reflection, because then i can directly serialise the data any ideas?

Ploetzeneder
  • 1,281
  • 4
  • 20
  • 34

3 Answers3

9

I had the same issue, the back button did not show. After looking in the DialogViewController.cs, I saw the constructor can take a second argument "pushing". If you set it to true, the back button is set to visible.

Darkwood
  • 111
  • 1
  • 7
3

The Back Button comes from a UINavigationController. You do need to either create a UINavigationController to hold your DialogViewController, or you need to manually customize your DialogViewController.

In the first case, you can use:

var ui = new UINavigationController (dv);

"ui" then contains your actual view controller, add that to your top-level window, or if you already have a view controller (for example, from some callback in your existing controller):

PresentModalViewController (ui, shouldAnimate);

Alternatively, you can customize your DialogViewController by hand, you can see how I do this in TweetStation on TweetStation/UI/Timeline.cs and add the buttons that you need.

miguel.de.icaza
  • 32,654
  • 6
  • 58
  • 76
  • I have the same problem, I have a `DialogViewController` nested within a `UINavigationController` which in turn is hosted inside a `UIPopoverController`. When I create a nested root within the root of my `DialogViewController` I don't get the back button? I have tried setting the `pushing` option as @Darkwood suggested below to no avail. Also, the controller of the nested root element is a `UITableViewController` not sure if that would have any affect. – James Mar 30 '12 at 15:10
  • 1
    In fact, it's ok I figured it out. My Title on the `DialogViewController` was being cleared! – James Mar 30 '12 at 15:19
1

I experienced the same issue and the reson was that the "Title" was missing, so navigation controller w/o a title doesn´t show a "back"-button.

The solution was easy, when i generated the root-elements i forgot for a title for first root like this:

var root = new RootElement("Settings"){ // <-- IMPORTANT! A title must be set here(!)
        new Section("Current server"){
            new RootElement("Server", new RadioGroup (0)){
                //...
            }
        },

My Constructor of the inherited DialogViewController for example:

public partial class SettingsViewController : DialogViewController
{
    public SettingsViewController () :
        base (UITableViewStyle.Grouped, null, true)
    {
        Root = GetRoot();
    }

This works like a charm ;-)

BTW: in viewwillappear i add a button and reload data:

public override void ViewWillAppear (bool animated)
{
        NavigationItem.SetRightBarButtonItem(
            new UIBarButtonItem("Add Server", UIBarButtonItemStyle.Plain, (sender,args) => {
            // button was clicked

            NavigationController.PushViewController(new AddServerDialogViewController(), true);

        }), true);

        //TableView.SetEditing(true, true);

        ReloadData();

        base.ViewWillAppear(true);
}