itemtemplate

WPF - ItemTemplate not acting as expected

为君一笑 提交于 2019-12-01 06:41:35
I have a UserControl which I'm using to display a list of UIElement s. The control consists of a single ItemsControl with it's ItemPanelTemplate switched for a horizontal StackPanel , its ItemsSource bound to a DependencyProperty exposed by the UserControl and its ItemTemplate set in the UserControl.Resources . Everything works fine except the ItemTemplate never get's applied and I can't see why. The full source is below. UserControl.xaml - <UserControl x:Name="UC" x:FieldModifier="private" x:Class="ContentSliderControl.ContentSlider" xmlns="http://schemas.microsoft.com/winfx/2006/xaml

If statement in repeaters ItemTemplate

假装没事ソ 提交于 2019-11-30 12:47:05
I'm using an ASP.NET Repeater to display the contents of a <table> . It looks something like this: <table cellpadding="0" cellspacing="0"> <asp:Repeater ID="checkboxList" runat="server" OnItemDataBound="OnCheckboxListItemBound"> <ItemTemplate> <tr id="itemRow" runat="server"> <td> Some data </td> </tr> </ItemTemplate> </asp:Repeater> </table> It works fine, but i'd like to have an if() statement inside the ItemTemplate so i can conditionally determine if i want to print out a <tr> tag. So i'd like to have something like this: <table cellpadding="0" cellspacing="0"> <asp:Repeater ID=

Binding to viewmodel from inside a datatemplate

自古美人都是妖i 提交于 2019-11-30 10:57:02
I have multiple videos displayed they are bound with a videocollection in Mainviewmodel. Everything works fine untill I try to bind the enter command to Mainviewmodel. I Don't know the syntax for this. As it stands the binding is set to Video and not Mainviewmodel. Errormessage: 'StartVideoCommand' property not found on 'object' ''Video' Xaml: <Window.Resources> <local:MainViewModel x:Key="MainViewModel"/> </Window.Resources> <Grid DataContext="{StaticResource MainViewModel}"> <ListBox ItemsSource="{Binding Videos}"> <ListBox.ItemTemplate> <DataTemplate> <Grid> <Grid.InputBindings> !!!

WPF Trigger for IsSelected in a DataTemplate for ListBox items

半城伤御伤魂 提交于 2019-11-30 06:14:37
问题 I have a listbox, and I have the following ItemTemplate for it: <DataTemplate x:Key="ScenarioItemTemplate"> <Border Margin="5,0,5,0" Background="#FF3C3B3B" BorderBrush="#FF797878" BorderThickness="2" CornerRadius="5"> <DockPanel> <DockPanel DockPanel.Dock="Top" Margin="0,2,0,0"> <Button HorizontalAlignment="Left" DockPanel.Dock="Left" FontWeight="Heavy" Foreground="White" /> <Label Content="{Binding Path=Name}" DockPanel.Dock="Left" FontWeight="Heavy" Foreground="white" /> <Label

If statement in repeaters ItemTemplate

夙愿已清 提交于 2019-11-29 18:24:21
问题 I'm using an ASP.NET Repeater to display the contents of a <table> . It looks something like this: <table cellpadding="0" cellspacing="0"> <asp:Repeater ID="checkboxList" runat="server" OnItemDataBound="OnCheckboxListItemBound"> <ItemTemplate> <tr id="itemRow" runat="server"> <td> Some data </td> </tr> </ItemTemplate> </asp:Repeater> </table> It works fine, but i'd like to have an if() statement inside the ItemTemplate so i can conditionally determine if i want to print out a <tr> tag. So i'd

Binding to viewmodel from inside a datatemplate

只谈情不闲聊 提交于 2019-11-29 16:21:38
问题 I have multiple videos displayed they are bound with a videocollection in Mainviewmodel. Everything works fine untill I try to bind the enter command to Mainviewmodel. I Don't know the syntax for this. As it stands the binding is set to Video and not Mainviewmodel. Errormessage: 'StartVideoCommand' property not found on 'object' ''Video' Xaml: <Window.Resources> <local:MainViewModel x:Key="MainViewModel"/> </Window.Resources> <Grid DataContext="{StaticResource MainViewModel}"> <ListBox

ItemsControl ItemTemplate Binding

痞子三分冷 提交于 2019-11-29 13:10:49
In WPF4.0, I have a class that contains other class types as properties (combining multiple data types for display). Something like: public partial class Owner { public string OwnerName { get; set; } public int OwnerId { get; set; } } partial class ForDisplay { public Owner OwnerData { get; set; } public int Credit { get; set; } } In my window, I have an ItemsControl with the following (clipped for clarity): <ItemsControl ItemsSource={Binding}> <ItemsControl.ItemTemplate> <DataTemplate> <local:MyDisplayControl OwnerName={Binding OwnerData.OwnerName} Credit={Binding Credit} /> </DataTemplate> <

multiple userControl instances in tabControl

风流意气都作罢 提交于 2019-11-29 08:06:35
I have a tabControl that is bound to an observable collection. In the headerTemplate, I would like to bind to a string property, and in the contentTemplate I have placed a user-control. Here's the code for the MainWindow.xaml: <Grid> <Grid.Resources> <DataTemplate x:Key="contentTemplate"> <local:UserControl1 /> </DataTemplate> <DataTemplate x:Key="itemTemplate"> <Label Content="{Binding Path=Name}" /> </DataTemplate> </Grid.Resources> <TabControl IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Path=Pages}" ItemTemplate="{StaticResource itemTemplate}" ContentTemplate="{StaticResource

Display multiple types from a single list in a WPF ListBox?

允我心安 提交于 2019-11-29 02:01:15
I have an ObservableCollection<Object> that contains two different types. I want to bind this list to a ListBox and display different DataTemplates for each type encountered. I can't figure out how to automatically switch the data templates based on the type. I have attempted to use the DataType property of the DataTemplate and attempted using ControlTemplates and a DataTrigger, but to no avail, either it nothing shows up, or it claims it can't find my types... Example Attempt below: I only have the one data template wired to the ListBox right now, but even that doesn't work. XAML: <Window x

What's the difference between ItemTemplate and ItemContainerStyle in a WPF ListBox?

梦想的初衷 提交于 2019-11-28 18:10:43
In WPF Listbox , I'm confused with these 2 notions: ItemTemplate and ItemContainerStyle Can someone explain me more? The ItemTemplate is for styling how the content of your data item appears. You use it to bind data fields, format display strings, and so forth. It determines how the data is presented. The ItemContainerStyle is for styling the container of the data item. In a list box, this would be a ListBoxItem. Styling here affects things like selection behavior or background color. It determines style and UX of the display. The MSDN page for ItemContainerStyle, linked above, has a pretty