You can try something like that. When I instantiate the TableViewSource, I
pass to it the items and the viewcontroller, that have a public method that
is called by RowSelected:
public ListViewSource (Form1 Parent, List<ListViewItem> rows)
{
this.Parent = Parent;
this.rows = rows;
// Code to mount items with or without sections
}
public override void RowSelected (UITableView tableView, NSIndexPath
indexPath)
{
Parent.listView_SelectedIndexChanged(null, null);
}
On parent class, I mean, ViewController parent of this source:
private void listView_SelectedIndexChanged(object sender, EventArgs e)
{
// Do something
}
Object sender and EventArgs aren't used here, but since to me it's the same
SelectedIndexChanged method of the Windows Mobile version, so it's there,
generated by VisualStudio 2 years ago from MonoTouch version. Soon just IB
things will be different than VisualStudio resource editor, the UI
manipulation will be exactly the same with a really few #ifs but it's
another story
Karl
From: Wally McClure <[email protected]>
Date: Wed, 8 Feb 2012 14:38:58 -0500
To: <[email protected]>, "[email protected]"
<[email protected]>
Subject: Re: [MonoTouch] I'm clearly completely misunderstanding something
fundamental... Help!
The reason why the methods and events are in a particular location is
because that is what Apple designed for their api. MT is just trying to be
a thin layer within your application that allows your c# code to call into
the vendor based api. Sometimes the apple api leaves me scratching my head
as well, so you aren't alone there. The reason for doing this is that for
the users, MT apps look just like other apps on the iPhone. The other
reason is that this gives the developer access to all the existing code to
learn from in the iPhone/objc world.
Without access to my code right now and trying to pull some things from my
horrible memory, isn't there a RowSelected override that you implement and
an NSIndexPath that is handed into your overridden method? I think you can
use those to get the row that is selected.
Wally
> Date: Wed, 8 Feb 2012 09:37:34 -0800
> From: [email protected]
> To: [email protected]
> Subject: [MonoTouch] I'm clearly completely misunderstanding something
fundamental... Help!
>
> I'm back to MonoTouch development after several months out, so I'm a little
> rusty (and I've only created a single, fairly simple app anyway).
>
> I've created my own UITableViewSource and UITableViewCell classes, as
> described in numerous places on the web, to enable me to customise the
> cell's appearance. In IB, I have dragged a UITableView directly onto the
> view, and have created an outlet for it.
>
> First problem: I expected to be able to create a RowSelected action in IB,
> but all I could create was an outlet or an outlet collection. I'm clearly
> missing something here. In my mind, the UITableView is similar to a control
> in .Net, complete with events. I expected such events to be exposed in IB,
> but obviously they're not. The RowSelected event is actually in the
> UITableViewSource, so I can understand why I can't create an action in IB,
> but this doesn't currently make sense to me. Why is the event tucked away in
> the source? I'm clearly looking at this all wrong.
>
> Secondly, how do I actually use the RowSelected event in my code? The event
> is tucked away in the UITableViewSource class, and I want to respond to it
> in the main view controller.
>
> I really though this would be simple (and I'm sure it should be).
>
> Thanks
>
>
>
> --
> View this message in context:
http://monotouch.2284126.n4.nabble.com/I-m-clearly-completely-misunderstanding-s
omething-fundamental-Help-tp4370234p4370234.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
_______________________________________________ MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch