Greetings.

I need some technical help with the following situation. I have a button on
my view controller. Now On touching it I want to display an action sheet
with a pickerview populated with data fetched from sqlite database. I have
my subclass of UiPickerViewModel defined, the function for fetching the data
from database in place. Now I am confused how to properly code for the
action sheet so that it shows the picker view. Rememner this is for iPAD.

Here is my subclass of pickerviewmodel.

------------------------------------------------------------------------------------------------
namespace ASTONAPP
{
        public class PickerDataItemSource:UIPickerViewModel
        {
                public PickerDataItemSource ()
                {
                }


                public PickerDataItemSource (List<PickerDataItem> lst)
        {
                this.Items=lst;
        } 

                public event EventHandler<EventArgs> ValueChanged;
                public List<PickerDataItem> Items 
                {
                        get 
                        { 
                                return this._items; 
                        } 
                        set 
                        { 
                                this._items = value; 
                        }
                }

                List<PickerDataItem> _items = new List<PickerDataItem>();


                public PickerDataItem SelectedItem 
                {
                        get 
                        { 
                                return this._items[this._selectedIndex]; 
                        }
                }
                protected int _selectedIndex = 0;


                public override int GetRowsInComponent (UIPickerView picker, int
component) 
                {
                        return this._items.Count;
                }

                public override string GetTitle (UIPickerView picker, int row, 
int
component) 
                {
                        return this._items[row].SiteName.ToString ();
                }


                public override int GetComponentCount (UIPickerView picker) 
                {
                        return 1;
                }


                public override void Selected (UIPickerView picker, int row, int
component) 
                {
                        this._selectedIndex = row; 
                        if (this.ValueChanged != null) 
                        {
                                this.ValueChanged (this, new EventArgs ());
                        }
                
GlobalVariables.TargetSiteToMoveID=Convert.ToInt32(this._items[row].SiteID.ToString
());

                }
        }
}
------------------------------------------------------------------------------------------------

Now in my view controller I am doing this: 

PickerSiteItemSource _pickerSiteSource;
DBHandler objdbh=new DBHandler();
UIActionSheet sheet1;
UIPickerView pkrsite;
UIButton doneButton = UIButton.FromType (UIButtonType.RoundedRect);

then on touch event of my button,
----------------------------------------------------------------------------------------------
partial void SiteClick (MonoTouch.UIKit.UIButton sender)
                {
                        pkrsite=new UIPickerView(new RectangleF(0f, 0f, 350f, 
350f));
                        this.CreatePickerSiteItems ();
                        pkrsite.Model=this._pickerSiteSource;
                        doneButton.SetTitle ("done", UIControlState.Normal);
                        doneButton.TouchUpInside += (s, e) => {
sheet1.DismissWithClickedButtonIndex (0, true); };
                        sheet1 = new UIActionSheet () { Style = 
UIActionSheetStyle.BlackOpaque };
                        sheet1.Frame=new System.Drawing.RectangleF(480f, 320f, 
300f, 300f);
                        sheet1.Bounds=new System.Drawing.RectangleF(0f, 0f, 
300f, 300f);
                        sheet1.AddSubview(pkrsite);
                        sheet1.ShowInView (this.View);
                }
----------------------------------------------------------------------------------------------
But as it stands I am not getting the result. What I am getting is a very
thin black line in the middle of my iPAD screen. It appears something is
missing wrt setting the bounds or frame of either the pickerview or the
actionsheet control. I have never used action sheet before. This is my first
time, so I am pretty clueless. Please help me rectify the code block and
help me meet the requirement.

One thing I noticed in the output window when that thin black line is being
presented is that, in the application output window I am getting two
messages:

* invalid height value 350.0 pinned to 216.0*

Please help me. I really need this.

Many Thanks. 
 



--
View this message in context: 
http://monotouch.2284126.n4.nabble.com/Action-Sheet-Containing-PickerView-Help-Needed-tp4656684.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to