itemscontrol

How to change the data template in itemscontrol based on index?

我的未来我决定 提交于 2019-12-11 16:57:31
问题 I am trying to create a dynamic UI for polynomial function. Since I do not know the order beforehand, I want to create it dynamically. I am setting my coefficient list as a items source of items control and planned to change data template based on the index. The template should work like this if (index > 1) { (coefficient text box) + *x ^ (index) + //Polynomial2 } else if (index == 1) { (coefficient text box) + *x + //Polynomial 1 } else if (index == 0) { (coefficient text box) //Polynomial }

How to Bind ComboBox Inside ItemsControl with Caliburn.Micro?

 ̄綄美尐妖づ 提交于 2019-12-11 16:47:45
问题 This is my project using WPF with Caliburn.Micro. In my view I have an ItemsControl that bound to a BindableCollection, in the coresponding ViewModel, of a record class (MemberVotes). The class just has two fields: MemberName and Vote. The ViewModel also has a second BindableCollection of type string (VoteOptions). The Handle method in the ViewModel loads the data into both BindableCollections. The MemberVotes is loaded from the database and the VoteOptions is loaded by adding a new string

ItemsControl with DataTriggers

房东的猫 提交于 2019-12-11 14:05:49
问题 Can someone provide a simple example how could you use DataTriggers on an ItemsControl? For example if i say something like this: <ItemsControl.Triggers> <DataTrigger Binding="{Binding Items.Count}" Value="2"> <Setter TargetName="DocHost" Property="UniformGrid.Rows" Value="2"/> </DataTrigger> </ItemsControl.Triggers> It gives me an error saying that ItemsControl expects an event trigger. Sadly i must use DataTriggers inside and ItemsControl. How can i do that? 回答1: You cannot use a

How to draw items with rectangles and margin, in a vertically repeating ItemsControl?

吃可爱长大的小学妹 提交于 2019-12-11 10:28:13
问题 I'm trying to visualize a List<MyCustomClass> . Each item should be in a rectangle (with rounded corners, but that is another mattter), repeated vertically with a margin between the items. I've tried this, but the items are overlapping: <ItemsControl Name="ItemsControl1"> <ItemsControl.ItemTemplate> <DataTemplate> <Canvas Margin="10,10,10,10" Background="CornflowerBlue" > <Rectangle Fill="Blue" Stroke="Blue" Width="350" Height="100"> </Rectangle> <TextBlock Text="{Binding Headline}" Canvas

Unable to drag drop items between bound itemscontrols

自作多情 提交于 2019-12-11 08:23:08
问题 iv'e got several bound itemscontrols which all play the role of of drop target i need to be able to drag drop items between these items controls . the problem is that the items control's are not recognized as drop targets by the drag drop framework The ItemsControl Panel : <ItemsPanelTemplate x:Key="TopPipePanelTemplate"> <StackPanel></StackPanel> </ItemsPanelTemplate> The DataTemplate : <DataTemplate x:Key="PipeDataItem" > <Ellipse Width="45" Height="45" Fill="{Binding IsMine,Converter=

2nd time binding to PointCollection not being rendered

狂风中的少年 提交于 2019-12-11 07:04:24
问题 I have an ItemsControl whose ItemsSource I assign (via code) an ObservableCollection (lets call it Items) of INotifyPropertyChanged objects (data model). This data model has a PointCollection property. The view (XAML) binds to this PointCollection on a PolyLine (on the Points attribute). Initially when i set this Items collection to the ItemsControl.ItemsSource, i can see that the lines are indeed rendered. Issue: When I set the ItemsControl.ItemsSource to something else (like another

Binding a List<KeyValuePair<string, List<DataTable>>> items control wpf

六眼飞鱼酱① 提交于 2019-12-11 06:22:50
问题 I need to display 2 datatables when a key value pair item in the list is expanded. And the key value pair item's key should be the expander header. The first table should be bound to the first data grid and second to the second grid. The problem is that the second 'item' on the ItemsControl displays the same value as the first one. (My guess is that the datagrid's ItemsSource binding is incorrect since the VM generates the data for the ListOfKeyValuePairs correctly.) <!-- Data grid template -

Items in ItemsControl takes width of First Item

淺唱寂寞╮ 提交于 2019-12-11 06:12:06
问题 WrapGrid in ItemsControl takes the width of the first item as the default width of all children items. Is there any workaround to make the itemwidth stretch according to each individual item's content? Here's My XAML. <Grid Grid.Row="2"> <ItemsControl Grid.Column="1" ItemsSource="{x:Bind articleTags}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapGrid Orientation="Horizontal"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Border

Set Grid Column Width to Bound Perctange

假如想象 提交于 2019-12-11 04:48:15
问题 I want to display a Rectangle with a dynamic Width based on a bound data source. I originally looked into using a Converter , but wasn't able to bind to the converter parameter to get a read dynamic width. My most recent attempt was binding the parent column to the UtilPct property, which is a decimal in my BrokerCredit object. I think this is using the decimal value as an absolute instead of a percentage display. How would I go about doing this? I'd like my Rectangle or the parent column to

UWP: Popup MaxWidth

亡梦爱人 提交于 2019-12-11 04:25:31
问题 I have a Popup which contains an ItemsControl (I can use ListBox if needed) which its items are arranged horizontally. Since the total width of the items can exceed the width of the screen, I need to limit the size of the popup width. My question is how can I limit the size of the popup? I've tried to use MaxWidth, but it doesn't work :( <Popup x:Name="puSoldItems" IsOpen="False" IsLightDismissEnabled="True" MaxWidth="{Binding ActualWidth, ElementName=_This}" ScrollViewer.HorizontalScrollMode