How can I make a column in a listbox in WPF the same width for all items?

You can use the IsSharedSizeScope attached property. In your template definition, attach a “shared size group” to each column, like this: <Grid.ColumnDefinitions> <ColumnDefinition SharedSizeGroup=”col1″ /> <ColumnDefinition SharedSizeGroup=”col2″ /> </Grid.ColumnDefinitions> … then define your ListBox as a shared size scope so it knows to size each “size group” the same way: <ListBox Grid.IsSharedSizeScope=”True”>…</ListBox>

two itemtemplates for one listbox

You can define DataTemplates that apply to any instance of a specific type by specifying the DataType without an x:Key. Using this method you don’t assign anything to ItemTemplate – the templates are applied automatically. <ListBox ItemsSource=”{Binding Path=MixedList}”> <ListBox.Resources> <DataTemplate DataType=”{x:Type local:BananaViewModel}”> <TextBlock Text=”{Binding Name}” Foreground=”Yellow”/> </DataTemplate> <DataTemplate DataType=”{x:Type local:AppleViewModel}”> <TextBlock Text=”{Binding Name}” Foreground=”Red”/> </DataTemplate> … Read more

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

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 … Read more

WPF Trigger for IsSelected in a DataTemplate for ListBox items

You can style your ContentControl such that a trigger fires when its container (the ListBoxItem) becomes selected: <ContentControl x:Name=”designerContent” MinHeight=”100″ Margin=”2,0,2,2″ Content=”{Binding Path=DesignerInstance}” Background=”#FF999898″> <ContentControl.Style> <Style TargetType=”{x:Type ContentControl}”> <Setter Property=”Visibility” Value=”Collapsed”/> <Style.Triggers> <DataTrigger Binding=”{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}” Value=”True”> <Setter Property=”Visibility” Value=”Visible”/> </DataTrigger> </Style.Triggers> </Style> </ContentControl.Style> </ContentControl> Alternatively, I think you can add the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)