Click here to Skip to main content
16,006,594 members
Home / Discussions / WPF
   

WPF

 
QuestionCanceling tab selection Pin
yanairon21-May-08 21:13
yanairon21-May-08 21:13 
QuestionBind CLR Object Instance To A ListBox Pin
BlitzPackage21-May-08 10:18
BlitzPackage21-May-08 10:18 
AnswerRe: Bind CLR Object Instance To A ListBox Pin
Insincere Dave21-May-08 13:18
Insincere Dave21-May-08 13:18 
GeneralRe: Bind CLR Object Instance To A ListBox Pin
BlitzPackage21-May-08 14:33
BlitzPackage21-May-08 14:33 
GeneralRe: Bind CLR Object Instance To A ListBox [modified] Pin
BlitzPackage21-May-08 14:36
BlitzPackage21-May-08 14:36 
GeneralRe: Bind CLR Object Instance To A ListBox Pin
Insincere Dave21-May-08 15:53
Insincere Dave21-May-08 15:53 
GeneralRe: Bind CLR Object Instance To A ListBox Pin
BlitzPackage22-May-08 6:36
BlitzPackage22-May-08 6:36 
GeneralRe: Bind CLR Object Instance To A ListBox Pin
Insincere Dave22-May-08 9:39
Insincere Dave22-May-08 9:39 
Is your custom ListBoxItem a subclass of listbox item or a normal ListBoxItem + DataTemplate (Recommended)? To create a DataTemplate right-click the listbox and choose Edit Other Templates > Edit Generated Items (ItemTemplate). You can also do this via the binding dialog that pops up.
I ended up with something like this:
<Window x:Class="EmployeeTest.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="296" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:EmployeeTest="clr-namespace:EmployeeTest">
	<Window.Resources>
		<ObjectDataProvider x:Key="EmployeesDS" d:IsDataSource="True" ObjectType="{x:Type EmployeeTest:Employees}"/>
		<DataTemplate x:Key="EmployeesTemplate">
			<Border BorderThickness="1,1,1,1" BorderBrush="#FF000000" Width="100" Margin="0,0,0,4">
				<StackPanel Orientation="Horizontal">
					<Image Source="{Binding Path=Image}" Stretch="None" Margin="4,4,4,4"/>
					<TextBlock Text="{Binding Path=Name}" VerticalAlignment="Center" Margin="0,0,4,0"/>
				</StackPanel>
			</Border>
		</DataTemplate>
	</Window.Resources>
    <Grid>
    	<ListBox IsSynchronizedWithCurrentItem="True" Margin="40,40,40,40" ItemsSource="{Binding Mode=OneWay, Source={StaticResource EmployeesDS}}" ItemTemplate="{DynamicResource EmployeesTemplate}"/>
    </Grid>
</Window>


If you have subclassed ListBoxItem which you probably don't need to do you may have to subclass the ListBox and override GetContainerForItemOverride. The other properties you mentioned are for altering the layout of the items e.g a horizontal listbox, the ItemTemplate is the one you need to set.
GeneralRe: Bind CLR Object Instance To A ListBox Pin
BlitzPackage22-May-08 14:52
BlitzPackage22-May-08 14:52 
GeneralRe: Bind CLR Object Instance To A ListBox Pin
BlitzPackage24-May-08 11:00
BlitzPackage24-May-08 11:00 
QuestionResource Dictionaries. Pin
Jammer21-May-08 6:04
Jammer21-May-08 6:04 
AnswerRe: Resource Dictionaries. Pin
User 27100925-May-08 8:14
User 27100925-May-08 8:14 
GeneralRe: Resource Dictionaries. Pin
Jammer26-May-08 10:16
Jammer26-May-08 10:16 
GeneralRe: Resource Dictionaries. Pin
User 27100926-May-08 10:35
User 27100926-May-08 10:35 
GeneralRe: Resource Dictionaries. Pin
Jammer26-May-08 11:12
Jammer26-May-08 11:12 
GeneralRe: Resource Dictionaries. [modified] Pin
Jammer26-May-08 23:36
Jammer26-May-08 23:36 
GeneralRe: Resource Dictionaries. Pin
Jammer27-May-08 6:38
Jammer27-May-08 6:38 
GeneralRe: Resource Dictionaries. Pin
User 27100927-May-08 8:47
User 27100927-May-08 8:47 
GeneralRe: Resource Dictionaries. Pin
Jammer27-May-08 8:58
Jammer27-May-08 8:58 
QuestionGet the top most child windows Pin
Rohde21-May-08 5:34
Rohde21-May-08 5:34 
AnswerRe: Get the top most child windows Pin
Jammer21-May-08 5:59
Jammer21-May-08 5:59 
GeneralRe: Get the top most child windows Pin
Rohde21-May-08 20:20
Rohde21-May-08 20:20 
GeneralRe: Get the top most child windows Pin
Jammer21-May-08 23:30
Jammer21-May-08 23:30 
GeneralRe: Get the top most child windows Pin
Rohde21-May-08 23:35
Rohde21-May-08 23:35 
GeneralRe: Get the top most child windows Pin
Jammer22-May-08 1:08
Jammer22-May-08 1:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.