listboxitem

Silverlight relativebinding ItemTemplate ListboxItem - Listbox

I created programatically a class (I called it ViewGrid) so that I use an instance of it as ItemTemplate for my ListBox control; of course, it's my data template for the listboxitem.... Also, in my ViewGrid class, I got a dependency property called IsChecked and I want to keep it in sync with the ListBoxItem's IsSelected property. I not...

How can I use VisualStateManager to change the text color (foreground) of a ListBoxItem?

Here's the deal. I can create a ListBox and style it. I can edit a copy of the template such that the States become available in Expression Blend 3. And I can change the state so that the background color of a line item is modified when selected. But I cannot change the foreground color of the text because of the ContentPresenter! Does a...

WPF: ListBox - setting focus on an item breaks keyboard navigation

After selecting ListBox item programmatically it is needed to press down\up key two times to move the selection. Any suggestions? View: <ListBox Name="lbActions" Canvas.Left="10" Canvas.Top="10" Width="260" Height="180"> <ListBoxItem Name="Open" IsSelected="true" Content="Open"></ListBoxItem> <ListBoxItem...

WPF Style Triggers: can I apply the one style for a variety of Properties?

It seems like there has to be a way to do this: I am applying an ItemContainerStyle in my Listbox, based on two property triggers. As you can see, I'm using the exact same set of trigger enter/exit actions, simply applied on two different properties. Is there something equivalent to a <Trigger Property="prop1" OR Property="prop2"> ???...

how can i show datagrid inside tooltip .. not tooltip for datagrid!

I have a listbox and its bound. and i have tooltip on listbox item sometihng like this <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <!--<EventSetter Event="MouseEnter" Handler="ListBox_MouseEnter" />--> <!--<EventSetter Event="MouseEnter" Handler="ListBox_MouseLeave" />--> <Setter Property...

WPF - ListBox ignores Style When ItemsSource is bound

Hi, I have created styled a ListBox in WPF so that it is rendered as a checkbox list. When I populate the ListBox's items manually, the styling works perfectly. However, when I instead bind the ItemsSource of the ListBox to a static resource (an ItemsControl containing the required items), the styling is completely dropped. Here's the...

Adding programatically a command to a listbox in WPF

In my WPF application there is a listbox with items. The listbox is populated via a xmldataprovider from XAML and then binding it to Itemssource property of the listbox. Well, from XAML, I bind a comand to the listbox by doing: <ListBox.CommandBindings> <CommandBinding ...

ListBoxItem IsSelected style

I still didn't get it. Could you please show me exactly how to override ListBox's default behavior. Everytime when ListBoxItem is selected the Border's background should be changed. Not the background of the whole row but only background of the border which's specified. <ListBox ItemsSource="{Binding Source={StaticResource Asset...

ListBoxItem.Parent returns nothing, unable to get it thru VisualTreeHelper.GetParent either

How do I extract the parent container of a ListBoxItem? In the following example I can go till the ListBoxItem, higher than that I get Nothing: <ListBox Name="lbAddress"> <ListBox.ItemTemplate> <DataTemplate> <Button Click="Button_Click"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> Private Sub Button_Click(...

How to define a ListBoxItem Template that has the same size of its parent?

I am using the following code: <ListBox x:Name="lbItems" Grid.Row="1" Margin="2"> <ListBox.Template> <ControlTemplate> <Border Background="{StaticResource DarkerBrush}" Width="{Binding Path=ActualWidth, RelativeSource={RelativeS...

silverlight 3 listbox item highlight versus selected.

I have a listbox and am attempting to select and item in code. Sometime one item is highlighted, that is it is background is colored blue, but a different item has a square blue box around the it (no highlighting just an hollow outline of a box). Am I correct in saying one is "highlighted" and one is "selected" and do I have them corre...

How to change the border on a listboxitem while using a predefined template

Hey, I'm using one of the defined wpf themes for my application, so all my controls automatically are pimped according to that theme. Now i am filling a listbox with items (usercontrols), but not all of them should be visible at all time. But when i'm setting height to 0 (of usercontrol) or setting to invisible, i get a thick grey bord...

Silverlight: how to modify the width of ListBox Items in response to user input?

I have a simple Silverlight 3 UserControl whose width increases or decreases based on user input. The controls become more wide or more narrow as desired, except for the ListBox items. The ListBox Items grow horizontally to fit their content regardless of HorizontalContentAlignment being set to 'Stretch'. Should I be able to set a pro...

ListBoxItem height not getting updated

Hi, I have a listbox inside another list box, in inner list box listboxitems height may grow or shrink. My problem is that when the inner items shrink the outer list box doesn't re-render its height. Thus - stays with the previous height before the inner list shrinked. I have tried so many things here, among Invalidate of all types, s...

how to get the items in listbox one by one in asp.net using c#

how to get the items in listbox one by one e.g : in my listbox i have items (roll no's) s1 s2 s3 s4 s5 etc... how to get the items on by one ...

WPF - How do I get an object that is bound to a ListBoxItem back

Hi there here is what I would like to do. I get a List of objects from a database and bind this list to a ListBox Control. The ListBoxItems consist of a textbox and a button. Here is what I came up with. Up to this point it works as intended. The object has a number of Properties like ID, Name. If I click on the button in the ListBoxIte...

Mouse interaction in ListBoxItem children (WPF)

I have a ListBox with an ItemTemplate that contains a control that interacts with the mouse. This interfers with the selection functionality of the ListBox, i.e. clicking a control does not select the item. This is because ListBoxItem sets the Handled property of the mouse event to true in OnMouseLeftButtonDown. I tried the following pr...

Can you set a gradient brush for a listboxitem background in silverlight?

I am looking for a way to set a gradientbrush as the background for a listbox item. I have a DataTemplate defined and have specified a gradient brush but it always appears as the listbox background (i.e. it never shows as a gradient brush). I have been able to set the background of the listbox itself, and I can set the listboxitem's ...

Set ListBoxItem.IsSelected when child TextBox is Focused

Hi, I have a typical MVVM scenario: I have a ListBox that is binded to a List of StepsViewModels. I define a DataTemplate so that StepViewModels are rendered as StepViews. The StepView UserControl have a set of labels and TextBoxs. What I want to do is to select the ListBoxItem that is wrapping the StepView when a textBox is focused. I...

Configure ListBox in WPF so that I will be possible to select multiple items without holding CTRL key

I have a Listbox that allows user to select multiple items. Normally user can do that by holding CTRL key and clicking the item he or she wants to select. Is it possible to configure this listbox so that the user will not have to hold the CTRL key when selecting items ? So that he or she will just click the item (without holding anythin...