I am trying to get a conversation-like style going with either a ListBox or Listview but so far unsuccessfully. I don't even know where to start in order to achieve this.
I know how to style ListBox and ListView in other ways, but this particular style I have no idea where to start.
Can anyone please help point me in the right direction? Below is the kind of style I am trying to achieve:
Notice how in the image above, list items are left-aligned, but every other list item is right aligned (but the text inside the item is left-aligned), and every second list item also has a different background color.
I would consider using a DataTemplateSelector. Create a different template for each of the styles. The template selector could select one style if it's user A and another for user B or something along those lines.
Related
I added a listbox control to log entries but I want the entries to have a date in the right side. Apparently, I'm able to only align it one side and not able to have this text on both the side. I was wondering if it is possible. Here's a photoshopped image to describe what I need. The right side date doesn't actually turn up. I added that through photoshop but its exactly what I need.
I would like to suggest you to use ListView instead of Listbox. You can show your list with multiple columns in detail view. You can also align column value, Hide header using HeaderStyle property.
If you don't want to use ListView control and want to use ListBox. then you have three options to do that.
You can draw item using OwnerDraw method.
You can add label to the ListBox. but, it creates lot of problems when you are trying to scroll items.
Set the listbox font Courier New and use String.PadRight or String.PadLeft to place space between two item. But, in this method the item will be return with space. Here you need to process to separate that field.
I have a program in MVVM. In this program i have a view with a DataGrid. In this datagrid i have to show something like this:
The user mark some cells and after MouseUp, should be created a button over this selected cells. The first Problem here is, how to get the Column and the Row. It is in the SelectedCellsChanged-Event Argument. With help from the WPF MVVM Light i can give my ViewModel the Event and the Arg, but my workmate had already problems with visual elements in a ViewModel(He was get a error in the visual tree). And i know that a visual element should not be in a VM. Can anyone here give me a way to get this Column and Row-Spawn?
My second problem that i can't imagine me how to create the buttons in the correct cell. If i think right is it possible to build a new VM for every Button(with Property StartRowSpawn, EndRowSpawn, StartColumnSpawn, EndColumnSpawn) or for each cell?
Can you give me tip, how to solve that?
I thinked about a grid too. Get position while MouseDown and MouseUp and then find the Grid.Column and Grid.Row for that.
Edit
Okay i done my first problem with Interfaces, but i already have my second problem. Can anyone help me there?
I would rethink why you need to do this(or maybe you can explain more why to need buttons like this). What I do when I need to change the design of data in a data grid is use an alternate datatemplate or the details datatemplate for the datagrid row to chnage the format of the infomration, then you can use the same view model. You can bind the column spans to properties in your viewmodel but it gets difficult if you want the button quantities to be dynamic.
I need to load a ListView entirely and get an UIControl inside each ListItem even if the item view is not displayed on the screen.
I tried the ChildViewAdded event, but it is raised only when the ListItem is displayed on the screen.
So, I need a way to prepare my UI ListView programmatically before displaying it.
Thanks in advance for your help.
Quick answer - if you need a real View for each item in your list then you don't want to use a virtualized control like a ListView.
Instead you can use repeated custom views inside a vertical LinearLayout inside a ScrollView.
If using mvvmcross, you may find a MVXBindableLinearLayout helpful to do this - it has an ItemsSource and a Template just like the MvxBindableListView.
I've no idea whether what you are trying to do makes sense, but the above should help you do it if you want to!
Don't try using a linear layout for lists with lots of items - you'll run out of resources.
I'm currently working on making a point of sale and I got it to show items in a ListView that are in the current sale. I did this by DataBinding an ObservableCollection of "Item"-type objects in a static "Sale" class called CurrentSale. Not bad, eh? But I need to add coupons and discounts to my pos now, and it's proving to be difficult with the way WPF is set up.
This:
http://dl.dropbox.com/u/1330689/listnow.jpg
is how the listview currently looks. This:
http://dl.dropbox.com/u/1330689/listgoal.jpg
is my mockup of how I'd like a discount to show up. I think I've got the discount and coupon part of the program under control, I'd just like to make them show up. I'd be super thrilled if someone could show me some sample code demonstrating how to insert a custom listviewitem into a listview that's already bound with data, and with similar characteristics(multiple cells, black background)
I read through this:
Append Items to Databound ItemsControl in WPF
and it looks like that guy's got a similar problem. The solutions given to him were to add a special item to the bound list, or to use a CompositeCollection. I can't add a "special" item to the observablecollection, because it doesn't let me change the background color, and I wanted a cleaner solution. Also, I couldn't really find any documentation on CompositeCollections with ListViews, so maybe somebody can shed more light on it(if it's relevant to my problem)
Thanks :)
I think you should use ListBox instead of ListView and DataTemplateSelector
Create base abstract class and 2 subclasses, for instance: BaseListItem, ProductListItem and DiscountListItem. Then insert specific object in the specific place into ObservableCollection<BaseListItem> used as ItemsSource for your ListBox.
So i have a listbox, and here is what im trying to acheive:
have the class style adding/selecting/removing sort of like a TreeView
ListBox items have more than one label docked to different sides of the space ( for example, the item would be thicker, and would be big enough for two labels on top of eachother, and then perhaps another off to the side)
when selected/not selected, the items will have a transparentish picture overlay
What I need to know:
Is there a (free/opensrouce) control that this can be easliy accoplish this
If No to 1, how should i begin to create this, (where to start, what to avoid etc)
I ended up using a user control, and created children that draw themselves, and then just included them in my listbox, so i got it working! thanks anyways guys