itemscontrol

access-like data navigation in WPF?

扶醉桌前 提交于 2019-12-04 19:54:18
What would be the best way to build a data-navigation like in access-forms in XAML/C#? Should I build a user control (or even custom control) that I just bind to my collection in which I can put other controls? (hence this question: C# User Control that can contain other Controls (when using it) ) Or can I build something by deriving from then ItemsControl somehow? how? Or would this be done completely different today (like "this style of navigation is so last year!")? I'm relatively new to C# and all (not programming as such, but with more like "housewife-language" Access-VBA) also I'm no

ItemsControl missing vertical scrollbar

假如想象 提交于 2019-12-04 17:47:25
问题 I have the below ItemsControl which wraps items perfectly but it does not have a vertical scrollbar so I can not see the wrapped items. How can I get the scrollbar to show? <ItemsControl x:Name="tStack" Grid.Column="0" Grid.Row="1" ItemsSource="{Binding Shows.View}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" BorderThickness="0.5"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top"/> <

Multiple user controls share collection dependency property

試著忘記壹切 提交于 2019-12-04 17:41:56
问题 I have implemented my own usercontrol based on listboxes. It has a dependency property with type of a collection. It works fine when I have only one instance of the usercontrol in a window, but if I have multiple instances I get problem that they share the collection dependency property. Below is a sample illustrating this. My user control called SimpleList: <UserControl x:Class="ItemsTest.SimpleList" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas

How do I bind a List<string> to an ItemsControl?

偶尔善良 提交于 2019-12-04 17:11:34
问题 In my presenter I have this property: public List<string> PropertyNames { get; set; } And I want to list out the names with a ItemsControl/DataTemplate like this: <ItemsControl ItemsSource="{Binding PropertyNames}"> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Value}"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> Since the generic list doesn't have named properties, how do I reference the value in my Binding statement? 回答1: let me answer this, it's

Horizontal orientated WrapPanel within ItemsControl lists vertically

北战南征 提交于 2019-12-04 11:36:58
问题 I have two DataTemplates defined within my XAML, each used for a seperate ItemsControl panel. The main ItemsControl lists Foo objects stored within an ObservableCollection object. The Foo object itself has its own set of items stored within as an ObservableCollection object. I tried to define the XAML in a way that allows for each of the ObservableCollection Foo items to be displayed with its name in a header (The first ItemsControl). From this the list within each Foo item itself should be

Bind to ActualHeight of Item ItemsControl

冷暖自知 提交于 2019-12-04 06:31:06
I have two separate ItemsControl s that appear side by side. The ItemsControl s bind to the same ItemsSource , but they display the data differently. Each item displayed on the left will most likely be smaller than the same item on the right. This causes a problem because the rows will not line up, so I need the item on the left to bind to the item on the right. ItemsControl ItemsControl |Item 1 |Item 1 |Item 2 |Item 2 |Item 3 | |Item 4 |Item 3 As you can see, Item 2 on the right is larger, so it throws off the alignment. So if I can bind left's Item 2 to right's Item 2's ActualHeight the

WPF ItemsControl - how to know when the items finished loading, so that I can focus the first one?

孤街浪徒 提交于 2019-12-04 06:30:47
I have an ItemsControl in my View, that is bound to an ObservableCollection from ViewModel. The collection is filled, and afterwards an event from VM to view is raised (think search results and SearchFinished event). I would like to move keyboard focus to the first item in an ItemsControl, but when I do it in View's code-behind when handling SearchFinished, the items are not yet rendered (the collection is filled already, but wpf's rendering is asynchronous and didn't happen yet), so there is nothing to focus (Focus() needs to have the items' visual tree already constructed). I wanted to do

Binding to CurrentItem in a ItemsControl

二次信任 提交于 2019-12-04 04:21:25
问题 The XAML below is basically trying to make a list of Button s (rendered from the Name property of objects in the Views collection in the current DataContext . When I click on a button the CurrentItem property of CollectionViewSource should change and the associated View should be displayed in a content presenter. OK. If I click in the ListBox in the XAML below it works exactly as desired. But, If I click a button in the UniformGrid (created by the items control) the CurrentItem property is

Synchronizing WPF control widths in a WrapPanel

自闭症网瘾萝莉.ら 提交于 2019-12-04 04:14:41
问题 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>

Scroll a new item in a ItemsControl into view

左心房为你撑大大i 提交于 2019-12-04 01:05:03
问题 I have an ItemsControl that is databound to a ObservableCollection . I have this method in the code behind which adds a new model to the list. I would then like to scroll the new item (at the bottom of the list) into view. I think the size of the ItemsControl is not yet updated when I am querying the size, since the ActualHeight before and after the addition of the model is the same. The effect of this code is to scroll to a point slightly above the new item. How would I know what the new