Data Binding ListBox in a User Control in the Silverlight Page - silverlight-4.0

I have a user control that has a ListBox with a bunch of other controls.
I need to be able to bind the ListBox control in the Silverlight Page.
I need to be able to do this, so that i can use my usercontrol on several different pages and bind it to different table on each page.
Any ideas of how this can be done?

You can expose a DP of type IEnumerable in your UserControl and, as you feel the property change, set your ListBox's ItemsSource to that property.

Related

XAML control that supports data binding except listview or listbox

Is there any XAML control that supports data binding except listview or listbox. I am developing an application using windows azure mobile services table. After retrieving the data from table I am binding the list to a listview as a small preview. When user will select any Item from the list view I want to display the details of the selected item. Which XAML control will be suitable for this task. I can use lots of TextBoxes and assign its Text property from C# code. I dont think It is a good practice. Thank you
If it's a better collection viewer you are looking for for, use a DataGrid. If you want to show more info, it's worth making another panel and showing more data there about the selected item (master detail pattern)
All XAML controls support data bindings. Use DataContext if you want children to access the binding, otherwise you can bind directly on the property.
For example, you could have a separate panel that is a Grid with a few child controls. This Grid's DataContext can be set to the DataGrid's SelectedItem, then it's child controls can easily bind to the item's properties.

Exposing internal objects of a user control in the properties view of the designer?

I've already had success exposing a collection of items in the vb.net designer using DesignerSerializationVisibility(Content). Now I have a new twist. The items in my collection for a certain custom control are immutable--i.e. items can neither be added nor removed. All I want is to expose the items of my collection in the properties panel of the designer so that a developer can tweak the individual properties of each item in the predefined collection of items.
When I tried DesignerSerializationVisibility(Content) it allows the developer to manage the items but rather than editing the existing items it attempts to re-add the items to the collection, which causes key collisions.
As a result I figured it might make sense to expose each item of the collection as its own property. I used DesignerSerializationVisiblity(Visible) and (Content) and both just display the type name in the properties window but the object it exposes is not visible in a way that it can have its properties manipulated.
Am I missing something or can this not be done? I read somewhere about using a TypeConverter. Is this right?
If I understand your Question correctly, you want to change a property to expandable property that has several sub-property.
If I understand properly, you must create a class that is derived from ExpandableObjectConverter. And use this class with TypeConverterAttribute for your property or that class that is related with your property.
For more information, please see my question that its link is offered in below:
Hide ellipsis (…) button of expandable property like “…” button of font property in the property grid

Datagrid View in a custom control

I am trying to add datagridview control in my custom control but i failed.
I started creating new project[windows custom control library], added datagridview control on it and also added a property naming "DGVMain" which refers to datagridview control.
I compiled it.
While testing i find its properties like visible and other working but when i click on columns property it doesn't work. i.e i cannot add/edit columns into the datagridview of my custom control.
Did i miss any steps or do i need to add some more actions?
As you don't have other control within your custom control, maybe an inherited user control would be more appropriate in this case and I'm sure it will also fix your problem.

Adding a custom item to a Silverlight ComboBox bound to ObservableCollection

I have a search screen within my application that has a ComboBox which is bound to an ObservableCollection in a ViewModel (the collection contains Organisation entities returned via WCF from an Entity Framework model).
I wish to add an item to the combo representing "All Organisations" - so the user does not have to specify an organisation when searching.
Is there a way of adding custom items to a ComboBox or do I have to add a dummy Organisation to the collection and carry out the necessary logic when this is selected.
Have a look at WPF combo box, adding an all options item, when binding to an Observable Collection. It describes one option which is a CompositeCollection.

How does the tooltip control enhance all controls on the form with a new property?

When answering another question I started to wonder how I could Add new properties to all controls in a form just like the ToolTip-control does.
For example I could use that to Add a "IsDirty"-flag to all textboxes just by adding the component to the form and it would handle this for every textbox.
When adding the tooltip-control to the form all controls magically gets a new property "Tooltip on tooltip1" that can be set both programatically and in design view.
I want to be able to do my own enhancer like that.
It's an Extender Provider.