itemscontrol

creating custom itemscontrol

99封情书 提交于 2019-12-02 23:00:13
I'm trying to create a custom control derived from ItemsControl . The ItemsControl is initialized with items, but they are not shown. the itemsControl : public class PipeControl : ItemsControl { static PipeControl() { DefaultStyleKeyProperty.OverrideMetadata(typeof(PipeControl), new FrameworkPropertyMetadata(typeof(PipeControl))); } public PipeControl() { Checkers = new ObservableCollection<Checker>(); Checkers.Add(new Checker()); Checkers.Add(new Checker()); Checkers.Add(new Checker()); Checkers.Add(new Checker()); Checkers.Add(new Checker()); } public ObservableCollection<Checker> Checkers {

How to get ItemsControl scrollbar position programmatically?

大憨熊 提交于 2019-12-02 18:52:03
问题 I have an attached behavior to an ItemsControl that scrolls down to the bottom whenever a new item is added. Since I am working on a chat type program, I don't want it to scroll if the user has the scrollbar anywhere other than the very bottom as that would be very annoying otherwise(Some chat programs do this and it's awful). How do I accomplish this? I don't know how to access the wrapping ScrollViewer, or otherwise figure out if I need to bring it into view or not. This is the behavior

Modifying an ItemsPanel's Grid RowDefinitionCollection

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 17:26:44
问题 This is a followup for ItemsControl has no children during MainWindow's constructor Based on the answer to SO question "WPF: arranging collection items in a grid", I have the following: <ItemsControl Name="itemsControl1" ItemsSource="{Binding MyItems}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Grid Name="theGrid" ShowGridLines="True" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemContainerStyle> <Style TargetType="{x:Type FrameworkElement}"> <Setter Property=

Obtain DataGrid inside ItemsControl from the binded item

你离开我真会死。 提交于 2019-12-02 13:46:37
问题 I have an ItemsControl that uses DataGrid in its template like this: <ItemsControl Name="icDists" ItemsSource="{Binding Dists}"> <ItemsControl.ItemTemplate> <DataTemplate> <DataGrid ItemsSource="{Binding}" Width="150" Margin="5" AutoGenerateColumns="False" IsReadOnly="True"> <DataGrid.Columns> <DataGridTextColumn Header="Key" Binding="{Binding Key}" Width="1*" /> <DataGridTextColumn Header="Value" Binding="{Binding Value}" Width="1*" /> </DataGrid.Columns> </DataGrid> </DataTemplate> <

How to get ItemsControl scrollbar position programmatically?

江枫思渺然 提交于 2019-12-02 10:24:01
I have an attached behavior to an ItemsControl that scrolls down to the bottom whenever a new item is added. Since I am working on a chat type program, I don't want it to scroll if the user has the scrollbar anywhere other than the very bottom as that would be very annoying otherwise(Some chat programs do this and it's awful). How do I accomplish this? I don't know how to access the wrapping ScrollViewer, or otherwise figure out if I need to bring it into view or not. This is the behavior class that I actually got from someone on StackOverflow. I'm still learning about behaviors myself. public

Changing the DataTemplate of a TreeView in runtime

牧云@^-^@ 提交于 2019-12-02 10:23:16
I have a TreeView with 3 levels in my WPF application. Level 1 and level 2 have their own HierarchicalDataTemplate . Level 3 has its own DataTemplate . Here is the XAML code: <Window.Resources> <HierarchicalDataTemplate x:Key="Level1Template" ItemsSource="{Binding Value}" ItemTemplate="{StaticResource Level2RedTemplate}"> <Border Background="Green"> <TextBlock Text="Level1"/> </Border> </HierarchicalDataTemplate> <HierarchicalDataTemplate x:Key="Level2RedTemplate" ItemsSource="{Binding Value}" ItemTemplate="{StaticResource Level3Template}"> <Border Background="Red"> <TextBlock Text="Level2"/>

Can one bind a combobox Itemssource from a datatemplate of a ItemsControl

让人想犯罪 __ 提交于 2019-12-02 07:29:29
Given ComboBox in the ItemsControl will have different items which is based on the DataContext of the item (not of the ItemsControl ). Can it be done? And how? Preferably from code behind. I have the following DataModel : class Tester { public Tester(string name, string surname) { Name = name; Surname = surname; } public string Name { get; set; } public string Surname { get; set; } public override string ToString() { return Name + " " + Surname; } } class TheT { public ObservableCollection<Tester> TesterObject; public TheT() { TesterObject = new ObservableCollection<Tester>(); } public string

How do I make an ItemsControl stretch to fill all availible space?

元气小坏坏 提交于 2019-12-01 23:18:24
问题 I have an ItemsControl, with its ItemsSource bound to a list of items. The size of each of the items is as small as they can be, what I need is for the control and the items in the control to stretch to fit all available space. I tried setting VerticalAlignment to Stretch on both the control, and its items (using a style). I also tried wrapping the ItemsControl in a DockPanel, and docking the ItemsControl to the bottom. How do I have the ItemsControl dynamically resize? Also some, but not all

Synchronizing WPF control widths in a WrapPanel

久未见 提交于 2019-12-01 22:36:38
I have this case <WrapPanel> <CheckBox>Really long name</CheckBox> <CheckBox>Short</CheckBox> <CheckBox>Longer again</CheckBox> <CheckBox>Foo</CheckBox> <Slider MinWidth="200" /> </WrapPanel> I want all the CheckBoxes inside the WrapPanel to be the same width. Adding the following almost accomplishes the desired effect <WrapPanel.Resources> <Style TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}"> <Setter Property="MinWidth" Value="75" /> </Style> </WrapPanel.Resources> However, I do not want to hardcode a specific width, rather let the largest CheckBox set the width (the

How do I make an ItemsControl stretch to fill all availible space?

孤街醉人 提交于 2019-12-01 22:06:32
I have an ItemsControl, with its ItemsSource bound to a list of items. The size of each of the items is as small as they can be, what I need is for the control and the items in the control to stretch to fit all available space. I tried setting VerticalAlignment to Stretch on both the control, and its items (using a style). I also tried wrapping the ItemsControl in a DockPanel, and docking the ItemsControl to the bottom. How do I have the ItemsControl dynamically resize? Also some, but not all, of the item's visibilities are set to Collapsed (through the same style). Will that be a factor in