XAML control that supports data binding except listview or listbox - xaml

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.

Related

How do i manipulate the data templates inside listbox in uwp

I am making a chat application using XAML in UWP.The side panel is consisting of users. like this.
Everything is in Listbox in which I have this template that consists one ellipse as a circle which is like an indicator,one user image,textblocks and one toggle switch.I have to give states to the toggle switch in on the state it should change the green color of circle and make it red.
I want to give this functionality in code c# in MainPage.cs. I made the object of toggle in toggled Event Handler but I am not able to access the other elements inside the data template like ellispse,textblock.
What is the other alternative way of doing this?
NOTE: It has to be in listbox because I want to use the same template for every user.
The best way to do this would be to use data binding.
You would define a ViewModel class for the item, which would contain a bool property and would react to the toggling of the switch in the setter or have a Command which you would execute when the state event changes using behaviors.
If you really want the code as a event handler on main page, you have some options. To get the item associated with the toggle, you can use its DataContext property and cast it to the data type you are using. Alternatively, you can use Visual Tree Extesnions provided by the UWP Community Toolkit. This enables you to find the parent (probably Grid) where you store all the item controls and then manually find the user image, TextBlock, etc.

VB.NET Exposing child control properties

For a custom control I'm making, the datagridview is pretty much only going to be a customized version of the original. However, so that other controls I have made can interact with it, I have made it inherit my MetroControl class.
Since I cannot add multiple "Inherits", I have placed a DataGridView and docked it inside the control. From here I can then influence and theme it. Most of the properties are handled by my theming (such as the "RowHeadersStyle" etc..
I need to push forward the "Columns" property of the DataGridView so that the user can interact with the same column setup screen that they would as if they were using the normal DataGridView. Is there any way I can simply forward this property (as it would make it much easier for both me and the user)?
Yes, you can add a property on your UserControl that just returns the Columns property on the DataGridView (Assuming that your DataGridView is stored in field named dataGridView):
public DataGridViewColumnCollection Columns {
get { return dataGridView.Columns; }
}
That's it

Replacing XAML binding based on visual state in Windows 8

I use the VisualStateManager-Element to re-locate some XAML-elements on my page based on the current Visual State.
My problem is that I use a gridview which has to become a listview when the window is snapped (because of the small horizontal space left). I bound some other elements to the gridview's selectedItem property. My first approach was to create a listview and show/hide it based on the visual state. I would need to update the binding of my other elements as well though ( from gridView.selectedItem to listView.selectedItem) which is apparently impossible in the visualstatemanager. Another possibility would be to change the binding from code behind.
Are there other solutions (preferably in XAML)?
I think the generally accepted answer would be that you should have a piece of xaml per visual state. You collapse the one that is not currently in use. You would only make changes or create bindings manually if you were going to do something that required a dynamic number of bindings or something similar. In this case you have a fixed set of bindings to a known set of UI elements, so you would simply setup all the bindings in xaml.

Data Binding ListBox in a User Control in the Silverlight Page

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.

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.