itemscontrol

ItemsControl DataTemplate Items showing side by side

百般思念 提交于 2019-12-14 02:11:31
问题 I've been researching this for quite long time now, can't find the answer. How can I display each item in my itemscontrol side by side? The following code displays each item's content side by side (label and textbox), but the next item is shown underneath. Let's say I have 3 items in my ItemsControl. The current behaviour is: Label Textbox Label Textbox Label Textbox What I want is: Label Textbox Label Textbox Label Textbox (side by side) The current code uses a stack panel whick sets the

Calculate sum , average based on list of items in WPF

两盒软妹~` 提交于 2019-12-13 20:05:25
问题 In WPF, I want to display sum, average values based on the List of Items provided. For example, I have an Employee object with Salary Property, and I want to calculate total salary based on the employee list. Also, the employee object is data bound to a Items control where the Salary will be edited/new Employee may be added to the list. Can anyone provide me a solution to achieve this? 回答1: I would do this: In your code behind or ViewModel (if your using MVVM) create a new dependency property

DataTemplates to display a collection of Points as Ellipses in WPF

半世苍凉 提交于 2019-12-13 16:54:18
问题 In my application, the user is supposed to click over an image, and as he clicks some dots appear. Also he can remove them by right clicking, etc. So I have a test project composed of a single Window (xaml + codebehind) with a canvas, and I am handling some of its events, as MouseMove and MouseLeftButtonDown which are going to add points to an ObservableCollection<Point> in code behind. I already have this, what I don't know is how I'm supposed to implement data-templating and databinding so

Gridsplitter in a Grid with an ItemsControl

微笑、不失礼 提交于 2019-12-13 14:32:18
问题 I'm trying to make a PropertyGrid Custom Control. The PropertyGrid will be very similar to the PropertyGrid used in Visual Studio. I've tried using the PropertyGrid of the Extended WPF Toolkit but you have to specify the category of a property with an attribute and we need to change the categories runtime. Which as far as I know is impossible with attributes. So I'm making the PropertyGrid myself. This is my code so far: The Generic.xaml: <ResourceDictionary xmlns="http://schemas.microsoft

How to Override PropertyChangedCallback of a predefined Dependency Property ItemsSource in a WPF ItemsControl

若如初见. 提交于 2019-12-13 09:28:27
问题 How to Override PropertyChangedCallback of a predefined Dependency Property ItemsSource in a WPF ItemsControl . I developed a WPF Custom Control inherited from ItemsControl . In that I used the predefined Dependency Property ItemsSource . In that I need to monitor and check data once the Collection gets updated. I searched a lot in google, but I can't able to find any related solution to fulfill my requirement. https://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol

WPF Itemscontrol shows duplicate entries

Deadly 提交于 2019-12-13 03:38:33
问题 I'm using an ItemControl to display a list of strings (like a suggestion-list). My problem is that it sometimes duplicates one entry.. I've tried to disable virtualization without success... this is my xaml-code: <ItemsControl ItemsSource="{Binding ResultList}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel Orientation="Vertical" IsVirtualizing="False" IsContainerVirtualizable="False" VirtualizationMode="Standard"></VirtualizingStackPanel> </ItemsPanelTemplate> <

Identifying the index/row number of the ItemsControl item that has been tapped via an event handler

随声附和 提交于 2019-12-13 03:10:03
问题 I've a list of locations the user has saved for future reference (this is for a weather app). I'm using an ItemsControl to present the list: <ItemsControl Grid.Row="0" x:Name="locations" ItemsSource="{Binding Path=Locations}" ItemTemplate="{StaticResource locationRow}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> This is the ItemTemplate: <DataTemplate x:Key="locationRow"> <StackPanel>

Binding from items in ItemsControl to ItemControl's DataContext

China☆狼群 提交于 2019-12-13 00:28:51
问题 I have a ComboBox with a custom ItemsTemplateSelector. The Items for the control are defined in xaml, like so: <ComboBox ItemTemplateSelector="{StaticResource CommonListSelectorTemplates}" > <local:MyItem Heading="First" Text="First Item"/> <local:MyItem Heading="Second" Text="Second Item"/> <local:MyItemWithValue Heading="Third" Text="Third Item" Value="{Binding TheValue}" /> </ComboBox> The third item has a Value property that I wish to bind to the TheValue property on the ComboBox's

ItemsControl data binding… binding to the current item isn't working

穿精又带淫゛_ 提交于 2019-12-13 00:25:23
问题 I have the following ItemsControl page... <Page x:Class="Kiosk.View.ItemListView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Converter="clr-namespace:Kiosk.Converter" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300" Margin="10" Title="ItemListView"> <StackPanel> <Button

ItemsControl has no children during MainWindow's constructor

我的未来我决定 提交于 2019-12-12 17:24:24
问题 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="Grid.Row" Value="{Binding RowIndex}" /> <Setter Property="Grid.Column" Value="{Binding