private void On_UIReady(object sender, EventArgs e) { _app = Application.Current; _myWindow = _app.MainWindow; _myWindow.SizeToContent = SizeToContent.WidthAndHeight; _listControl = new ControlHost(ControlHostElement.ActualHeight, ControlHostElement.ActualWidth); ControlHostElement.Child = _listControl; _listControl.MessageHook += ControlMsgFilter; _hwndListBox = _listControl.HwndListBox; for (var i = 0; i < 15; i++) //populate listbox { var itemText = "Item" + i; SendMessage(_hwndListBox, LbAddstring, IntPtr.Zero, itemText); } _itemCount = SendMessage(_hwndListBox, LbGetcount, IntPtr.Zero, IntPtr.Zero); numItems.Text = "" + _itemCount; }
private void On_UIReady(object sender, EventArgs e) { _app = Application.Current; _myWindow = _app.MainWindow; _myWindow.SizeToContent = SizeToContent.WidthAndHeight; _listControl = new ControlHost(ControlHostElement.ActualHeight, ControlHostElement.ActualWidth); ControlHostElement.Child = _listControl; _listControl.MessageHook += ControlMsgFilter; _hwndListBox = _listControl.HwndListBox; for (var i = 0; i < 15; i++) //populate listbox { var itemText = "Item" + i; SendMessage(_hwndListBox, LbAddstring, IntPtr.Zero, itemText); } _itemCount = SendMessage(_hwndListBox, LbGetcount, IntPtr.Zero, IntPtr.Zero); numItems.Text = "" + _itemCount; }