itemscontrol

Change element inside Template

£可爱£侵袭症+ 提交于 2021-02-11 16:11:40
问题 I want to reuse the the ItemsControl from my ListView and its not really hard to put the ItemsControle into an Template. The problem is, I want to change the DataTemplate when I use my ItemsControlTemplate. <ListView DataContext="{Binding Input}"> <ItemsControl ItemsSource="{Binding Columns}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Grid> <Grid

WPF - UserControl default Content attribute

陌路散爱 提交于 2021-02-05 20:22:52
问题 I'm creating a UserControl and I just can't remember the name of the attribute which you use to decorate the property which you want to act as the default content property. To give a concrete example, say i have a property called 'Title' which i can set using property syntax like this - <local:myControl Title="the title"/> But the consumer of the control may want to use element syntax like this - <local:myControl> the Title </local:myControl> I KNOW there is an attribute which I need to add

TwoWay Binding With ItemsControl

不打扰是莪最后的温柔 提交于 2021-02-05 02:21:45
问题 I'm trying to write a user control that has an ItemsControl, the ItemsTemplate of which contains a TextBox that will allow for TwoWay binding. However, I must be making a mistake somewhere in my code, because the binding only appears to work as if Mode=OneWay. This is a pretty simplified excerpt from my project, but it still contains the problem: <UserControl x:Class="ItemsControlTest.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas

TwoWay Binding With ItemsControl

喜你入骨 提交于 2021-02-05 02:21:34
问题 I'm trying to write a user control that has an ItemsControl, the ItemsTemplate of which contains a TextBox that will allow for TwoWay binding. However, I must be making a mistake somewhere in my code, because the binding only appears to work as if Mode=OneWay. This is a pretty simplified excerpt from my project, but it still contains the problem: <UserControl x:Class="ItemsControlTest.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas

Populating ItemsControl Using Uniform Grid as ItemsPanel Column First

我只是一个虾纸丫 提交于 2021-01-29 10:02:57
问题 I have an ObservableCollection of 24 Things. private ObservableCollection<Thing> things; public ObservableCollection<Thing> Things { get => things; set { things= value; RaisePropertyChanged(); } } I also have a selected Thing private Thing selectedThing; public Thing SelectedThing { get => selectedThing; set { selectedThing= value; RaisePropertyChanged(); } } I need to display these items in a grid. I am creating a grid of buttons, each with a command and a command parameter that allows me to

How to setup a grid as template for an Items control?

大兔子大兔子 提交于 2021-01-20 19:01:06
问题 I'm trying to create an ItemsControl that uses a grid as its ItemsPanel in such a way that it has two columns, where the first columns width is the width of the widest item in that column, and has as may rows needed to display all the items Basically, I want the following, but somehow within an ItemsControl so that I can bind to a collection of objects: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions

How to setup a grid as template for an Items control?

与世无争的帅哥 提交于 2021-01-20 18:57:48
问题 I'm trying to create an ItemsControl that uses a grid as its ItemsPanel in such a way that it has two columns, where the first columns width is the width of the widest item in that column, and has as may rows needed to display all the items Basically, I want the following, but somehow within an ItemsControl so that I can bind to a collection of objects: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions

Filtering ICollectionView binded to ItemsControl

不打扰是莪最后的温柔 提交于 2020-11-25 03:56:50
问题 I want to make an WPF app for browsing recipes for dishes. Having trouble with filtering data. I'm using ItemsControl to make my data look like "tiles" in the window. Now i want to filter it with TextBox, but I cant figure what is wrong. Here is my XAML binding: <ItemsControl ItemsSource="{Binding}" Height="573"> Textbox: <TextBox x:Name="Szukaj" Text="{Binding Szukane, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Left" Height="27.667" Margin="18.667,145,0,0" IsEnabled="True"

WPF How to set a maximum amount of results from CollectionViewSource

时光怂恿深爱的人放手 提交于 2020-02-03 07:29:29
问题 I am trying to display a set of data using a DataTemplate in an ItemsControl , with the ItemsPanel set as a uniform grid of size 3 x 3. The ItemsSource of the ItemsControl is set to bind to a CollectionViewSource which filters the source collection based on a search term. This all works fine. The list I am binding to is of an arbitrary size, but I only want 9 results to be displayed, but I can't for the life of me work out how to either: a) limit the CollectionViewSource to output the first 9