I am currently using a Linq template with SubSonic3 to create my models. I have a simple Member class, which has a collection of Notes. A Note class has a PublishedDate and Title properties.
I have a UserControl which has a collection of Members for its DataContext. There are two ListBoxes and a bunch of TextBoxes and other controls on it. The first ListBox (membersList) gets its ItemsSource from the UserControl DataContext and it displays a few Member properties in each item. I would like the second ListBox (notesList) to display the Notes collection of the Member selected in the first ListBox.
So far on notesList I have:
<ListBox ... ItemsSource="{Binding Notes}"...>
<DataTemplate>
<TextBox Text="{Binding Title}"/>
</DataTemplate>
It partially works. When I selected a Member which has Note items there is the correct number of items in notesListBox but this is only visible in the alternating row colours - nothing else! The DataTemplate fails to render the Title of the Note. Basically all the visual styles in the ListBox and ListBoxItem works - alternating colours, selection border, mouseover, etc. but the content is not shown. I have a feeling the problem is my Binding syntax but I can't figure out what's wrong.
Any suggestions would be greatly appreciated.
Cheers,
Dany.
Make sure your template includes a ContentPresenter. It sounds like you may have left this out when you templated your list box.
Leaving this out could lead to the behavior you're experiencing - full template, but no "content", since there's no place for it to place the actual items that should go in each list box item.
Related
I use the same DataTemplate to populate some of the views inside my CarouselView: a XAML file with a ContentView. I assign a custom class list to ItemsSource of the carouselview AND use bindings inside the template layout fields to fill them with the properties of my custom class. Everything is working fine. Here comes the wierd part: Let's say there's a button in the template and when you click it on the screen, a Label with "Well Done" text is added to the current Stacklayout of the shown carouselview. This is done by the codebehind of my template XAML. This is ok, too, but I expect this "Well Done" to disappear after I swipe back and forth enough. Because it's not part of the template. It does not disappear, instead I see it on other carousels once in every 4 swipes and it is replaced, I mean it appears on different carousels if I swipe back and forth. To make it disappear completely I have to swipe away from the views that share the same DataTemplate. I cannot understand the mechanics behind this behaviour. I can create another field inside the template to put the "Well Done" text there and show it when the time comes, I know. But I want to understand the mechanics. Thank you.
Asking the right question about a problem is the key to any solution..
After the realization that I've mentioned at the Update comment, I've searched for DataTemplate Caching and found this issue post on Xamarin.Forms Github: https://github.com/xamarin/Xamarin.Forms/issues/9200
There you can find an explanation to how CollectionView was designed and understand the mechanics behind the behaviour. No bug. It's by design.
I have a Xamarin forms application. It has a page. That page has a listview. The listviews is bind to a sourcelist. What I want is to decide what custom control to use based on a specific property that each item in the list has. How can I achieve this?
It is also required that the custom control binds to values from the list.
I tried the following:
<ContentView Content="{Binding IsPriority, Converter={StaticResource RoadIndicatorBackgroundValueConverter}}" ControlText="{Binding TowingOrder.Location.RoadIndicator}"></ContentView>
That won't work because I can't bind with the ControlText of the specific custom control.
The image above shows the problem. The A1, A50 and the blue icons are all custom controls, those aren't images. There are some more of these custom controls. I can't just make 10 datatemplates right and copy paste everything? That would be so much duplicate code. Can't I just use a base object in a datatemplate, and bind a property with a converter and use a switch/case to decide which custom control to return?
It is not a good design to binding the content of whole layout in runtime.
From the screen shot , it seems that each cell are similar .So you could create a base Custom Control and define all controls in advance and binding the propertyIsVisible in code behind . Then set its value to control which element should been displayed .
If there are do many dig differences between the cells , use DataTemplateSelector is better .
I'm going insane over this issue. Basically, I have a TileList with a custom item renderer that has a TextInput in it. Let's say that the list can show 4 items at once, if there are 5 items and I edit the text on the first one, the fifth will be edited also. In general if an item is out of view, it will be change when I edit one that is showing.
Also, I had overriden the TileList class to expose the rendererArray property (so that I could access the texts on each renderer) but it will only return the renderers which are displayed.
Any help is appreciated. I need to know how to override this weird behaviour with itemrenderers that aren't currently displayed. Thanks.
Ok, if anyone runs into a similar issue, here is what you need to do:
First of all, avoid trying to iterate through the itemrenderers like I did. If you need a TextInput or another control on your TileList, make sure that these controls are bound to a property on your data object, otherwise off-screen items will have incorrect values since their itemrenderers will be recycled from the items that left the screen when you scrolled.
If you think it through, any requirement can be solved by iterating through the dataprovider instead of the itemrenderers.
Also, if you try to expose the rendererArray property like I did, notice that you will only be able to iterate through the itemrenderers that are currently displayed, since those that would belong to the items that are off-screen will not be created yet.
I hope this wasn't too confusing..
first time posting here.. so go easy =)
I am trying to learn the Workflow model, and ended up creating my own activity. Below is the XAML for the combo box in question.
<ComboBox ItemsSource="{Binding Source={StaticResource PossibleValues}}" SelectedValue="{Binding Path=ModelItem.SelectedEvent, Converter={StaticResource LifeEventConverter}}"
I have the following property defined in my Code Activity:
Public Property SelectedEvent As LifeEvents
The code works, my problem is whenever I close and reopen visual studio the combo box does not keep the last selected item. The property does keep it's value, but it driving me nuts that I can't tell what item is selected just looking at my workflow.
Does anybody have any ideas?
Can't tell for sure what the problem is but for a start the normal way to define input arguments to an activity it by creating properties of type InArgument. Not sure if that will solve your problem though.
The first thing I would check is if selected value, or anything else, shows up in the XAML for SelectedEvent.
I have a Listview in my aspx page with Insert template and Edit template. and a Add New LinkButton.
When a user clicks on Add New LinkButton I am able to specify Insertitem Position so that the Insert TEmplate appears at the bottom of the listview. But how to I make the edititem template to appear at the bottom like the Inserttemplate
Its not available for the EditItemTemplate.
You'd have to actually save the original position, move the item in the data source itself (probably IList compatible), rebind the view, trigger editing on the new position, then swap the data item back to the original position.
I wouldn't recommend it. It's nonintuitive behaviour for users anyway; when I decide to edit something I should either be able to edit in place or edit on an entirely separate form. It's very rarely good UI design to shuffle items around while users are working on them, especially if you have any sort of scrolling/paging going on.