itemtemplate

ASP.NET Repeater Template, Conditional Code for every Nth element

十年热恋 提交于 2020-01-01 04:19:35
问题 I'm using an asp.net repeater to create a bunch of images. The image markup is all the same so the standard <ItemTemplate> is fine. However, I want to wrap K images in a div. Lets say I bind 25+ images to the repeater and I want 5 images per div. How do I go about conditionally creating the start and close tags for the div? Is this a case better suited for a for loop. 回答1: This should work for you, with no need for anything in the code behind (other than binding the repeater..): <asp:Repeater

Strange focus behavior for simple WPF ItemsControl

£可爱£侵袭症+ 提交于 2020-01-01 03:39:51
问题 I'm seeing strange behavior when it comes to focus and keyboard navigation. In the example below I have a simple ItemsControl that has been templated so that it presents a list of CheckBoxes bound to the ItemsSource. <ItemsControl FocusManager.IsFocusScope="True" ItemsSource="{Binding ElementName=TheWindow, Path=ListOStrings}"> <ItemsControl.ItemTemplate> <DataTemplate> <CheckBox Content="{Binding}" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> For some strange reason the

Dynamically change the class of a div nested in a gridview item template from code behind c# [closed]

只愿长相守 提交于 2019-12-31 07:43:07
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 years ago . I need to change the class of a div nested inside a gridview item template, i have given the runat="server" tag and an id for the div. How can we change the class of that particular div upon gridview databind based on each row conditions. 回答1: ASPX <asp:GridView ID="gv" runat="server"

LongListSelector different item template for first and last item

半腔热情 提交于 2019-12-29 08:03:42
问题 Im writing my Windows phone 8 app which uses LongListSelector to display some data. How to set different item template for first and last item in LongListSelector? Basically I just want to display same information in every item but use little different item "layout" in last and first item. 回答1: You could implement some kind of data template selector to help in determining which template to select based on index. You can start off by creating a reusable abstract TemplateSelector class. I used

Change style of last item in ListBox

两盒软妹~` 提交于 2019-12-28 06:35:12
问题 I have listbox control which has list of colors. Here is code and Image: <ListBox Name="FillSelections" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Center" SelectedItem="{Binding SelectedColor}" SelectionMode="Single" Style="{StaticResource HorizontalListBoxStyle}" ItemsSource="{Binding FillColors}" ItemTemplate="{StaticResource ColorsItemTemplate}"></ListBox> <DataTemplate x:Key="ColorsItemTemplate"> <Border BorderBrush="Transparent"> <Rectangle Width="20" StrokeThickness=

Scrolling list items in wpf

為{幸葍}努か 提交于 2019-12-25 04:29:22
问题 I guess the following picture depicts the problem better than texts... alt text http://img179.imageshack.us/img179/8949/samplescrollingitems.png That is what I need. <ListBox x:Name="NamesListBox" ItemsSource="{Binding}"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel x:Name="ItemWrapPanel"> <WrapPanel.RenderTransform> <TranslateTransform x:Name="ItemWrapPanelTransformation" X="0" /> </WrapPanel.RenderTransform> <WrapPanel.Triggers> <EventTrigger RoutedEvent="WrapPanel.Loaded">

Stretch line to width of Itemstemplate canvas in itemscontrol

狂风中的少年 提交于 2019-12-24 09:36:46
问题 I have this code. For some reason I can't get the contentpresenter to stretch to fill the width of the canvas. Several of my attempts are commented out in the xaml. <ItemsControl ItemsSource="{Binding MarkerLocations, Mode=OneTime}" HorizontalContentAlignment="Stretch"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemContainerStyle> <Style TargetType=

Create ItemTemplate for ListBox in code-behind in WPF - Part II

╄→尐↘猪︶ㄣ 提交于 2019-12-23 22:34:38
问题 I named this question of mine Part II since I've already asked a similar but simpler question about creating an ItemTemplat for ListBox in WPF in here Create ItemTemplate for ListBox in code-beind in WPF Now I'm going to expand my question. I want to have an ItemTemplate for a ListBox so that it can be used either with or without binding to an ObservableCollection. If I don't want to bind the ItemsSource to an ObservableCollection I use the code as follows: var textBlockFactory = new

WPF Programmatically create treeview itemtemplate/columns

和自甴很熟 提交于 2019-12-23 09:58:56
问题 I have an application that reads database tables and puts it into a treeview. The current ItemTemplate for the treeview looks like this: <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding SubOrganLocations}"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="35" /> <ColumnDefinition Width="35" /> <ColumnDefinition Width="35" /> </Grid.ColumnDefinitions> <TextBlock Grid.Column="0" Text="{Binding OrganDisplayName}" /> <TextBox Grid

WPF: Adding an image to a ListBox ItemTemplate

十年热恋 提交于 2019-12-23 09:48:27
问题 I am creating a WPF app with a list box that I am binding to project names. As a decorative element, I want to place a small icon next to each item in the list, similar to the way Outlook does in its Personal Folders list. For starters, I am going to use the same image for all items in the list. Here is the markup that I've got so far (I'll move it to a resource dictionary after it's working): <ListBox.Resources> <ImageBrush x:Key="ProjectIcon" ImageSource="Images/project.png" /> </ListBox