English 中文(简体)
最新数据
原标题:Access last databound ListBoxItem

I m working on a WP7 app where I use a pre-populated SQLCE database. Therefore I use a lot of databound controls. Right now I m a bit in trouble. To keep it short: I need to access the last ListBoxItem (not the business object) of a databound ListBox and change some Properties like the Margin of that last Item. I was not able to get this Item by using the methods of the VisualTreeHelper class nor by using something like

(myListBox.Items.Last() as ListBoxItem).Margin = new Thickness(0, 0, 0, 0);

我 ListBox. 项目似乎无效(!)

There is some black magic going on, so is there a simple way? Thank you in advance!

最佳回答

事实不是直接尝试和操纵《国际调查》,而是因为不仅修改了你对清单具有约束力的数据,而且增加了财产以表明它是否是最后的。 然后,NYOu可以在数据模板中使用这种财产来控制如何展示这种财产。

问题回答

页: 1 ListBoxItem through ItemContainerGenerator?

((ListBoxItem)myListBox.ItemContainerGenerator.ContainerFromIndex(myListBox.Items.Count-1)).Margin = new Thickness(42, 0, 0, 0);

这应当行之有效。 否则,与你具有约束力的问题就是错误的。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签