listboxitem

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

独自空忆成欢 提交于 2019-12-08 07:57:55
问题 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"> ??? (Obviously wouldn't look like that, but that probably gets the point across.) <Style x:Key="ListBoxItemStyle" TargetType="ListBoxItem"> <Style.Triggers>

WPF - Retrieve Child DataTemplate Control From Custom ListBoxItem

断了今生、忘了曾经 提交于 2019-12-08 05:23:20
问题 In my application, I have a ListBox with a custom DataTemplate. The XAML is as follows: <ListBox Name="lstTasks"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" VerticalAlignment="Top"> <CheckBox Name="chkIsChecked" VerticalAlignment="Top" IsChecked="{Binding Path=IsChecked, Mode=TwoWay}"/> <RichTextBox Name="rtbTask" HorizontalAlignment="Left" Height="50" VerticalAlignment="Top" Width="450" BorderBrush="{DynamicResource {x:Static SystemColors

Why is a ListBoxItem not calling MeasureOverride when its width is changed?

大城市里の小女人 提交于 2019-12-08 04:28:20
问题 Ok, for illustrative purposes, below I created a subclass of ListBoxItem and a subclass of ListBox which uses it as its container by overriding both IsItemItsOwnContainerOverride and GetContainerForItemOverride . Now when the window first appears, as expected, MeasureOverride is called on every ListBoxItem (with Infinity,Infinity) followed by ArrangeOverride being called on every item. However, when resizing the ListBox , only ArrangeOverride is called on the ListBoxItem , not MeasureOverride

WPF - Retrieve Child DataTemplate Control From Custom ListBoxItem

不问归期 提交于 2019-12-08 03:54:40
In my application, I have a ListBox with a custom DataTemplate. The XAML is as follows: <ListBox Name="lstTasks"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" VerticalAlignment="Top"> <CheckBox Name="chkIsChecked" VerticalAlignment="Top" IsChecked="{Binding Path=IsChecked, Mode=TwoWay}"/> <RichTextBox Name="rtbTask" HorizontalAlignment="Left" Height="50" VerticalAlignment="Top" Width="450" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveCaptionTextBrushKey}}" Margin="0,0,0,10"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> I use a

Why is a ListBoxItem not calling MeasureOverride when its width is changed?

让人想犯罪 __ 提交于 2019-12-06 20:01:31
Ok, for illustrative purposes, below I created a subclass of ListBoxItem and a subclass of ListBox which uses it as its container by overriding both IsItemItsOwnContainerOverride and GetContainerForItemOverride . Now when the window first appears, as expected, MeasureOverride is called on every ListBoxItem (with Infinity,Infinity) followed by ArrangeOverride being called on every item. However, when resizing the ListBox , only ArrangeOverride is called on the ListBoxItem , not MeasureOverride even though the metadata for the width property is set to AffectsMeasure . NotE: I know I can get

ListBox with single select and also unselect on click…?

戏子无情 提交于 2019-12-06 17:25:25
问题 I need a listbox that selects on first click and un-selects on second click, so that only zero or one item is selected at any time. The select/unselect is implemented in the listbox (with SelectionMode="Single") when you hold down crtl, but unfortunately, none of my users can be expected to know that. With SelectionMode="Multiple" we have the exact functionality I want, except that you can select more than one item... More background: I want the user to first choose which installation to log

Change style for all ListBoxItem in a ListBox (Windows phone 8)

删除回忆录丶 提交于 2019-12-06 15:12:31
I have a Listbox with some Listboxitem and I would like to change the style of all items. I know, it's possible to create a style in resources and bind this style to each item but maybe is there a possibility to do it so easier (without binding)? With ListBox.ItemTemplate? <ListBox SelectionChanged="ListBox_SelectionChanged"> <ListBoxItem x:Name="ItemAdress"> .... </ListBoxItem> <ListBoxItem x:Name="ItemPhone"> .... </ListBoxItem> <ListBoxItem x:Name="ItemEmail"> .... </ListBoxItem> </Listbox> In fact, my objective is to add Margin bottom 15 for each item. (add a space between items) Note:

WPF. ListBox item style

空扰寡人 提交于 2019-12-06 08:38:35
问题 I have problem with ListBox item style, I create two styles and do not know to use it together. 1st style is for ListBox item size, mouse over color and so on, or second is for item background (Alternation count). If I leave one of them they work fine, but how to make them work together? Or maybe I could it write in one style? My code is: ..... <Style x:Key="Style2" TargetType="{x:Type ListBoxItem}"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="OverridesDefaultStyle

WPF Listbox separator is shown with different thickness

戏子无情 提交于 2019-12-06 04:04:38
I have created a custom ListBox with each item separated by separator. But I am seeing weird issue. The thickness of separator is not constant across List items. It changes if I change the position of list box as shown in this List Box Image . Below is the source code of custom listbox. <Window x:Class="CustListBox.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:CustListBox" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <local:Manager x:Key="manager"/> <Style x:Key=

how to add user controls as listbox items

无人久伴 提交于 2019-12-06 02:19:45
问题 I am using WPF .net 4.5 (c#) and I would like to make a ListBox that contains a series of user controls. (If a listbox is the wrong type of control, please let me know). I want my listbox to have a copy of the user control as the list items, with different contents within each one. How do I add user controls to a listbox? Thanks for your help in advance! 回答1: You can set ItemTemplate for the listbox with your usercontrol in it. <ListBox> <ListBox.ItemTemplate> <DataTemplate> <local