Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

33
Pimp My Listbox Rainer Stropek cubido business solutions gmbh

Transcript of Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

Page 1: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

Pimp My Listbox

Rainer Stropekcubido business solutions gmbh

Page 2: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.
Page 3: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.
Page 4: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.
Page 5: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

enter the the presentation name in the footer field 5 18.10.2007

Page 6: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.
Page 7: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

Window

StackPanel

TextBlock

TextBox

ElementBaum

Page 8: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

Logischer undBorder

AdornerDecorator

AdornerLayer

ContentPresenter

String

String

... (ScrollViewer, Grid, Rectangle, ScrollBar, etc.)

StackPanel

TextBlock

TextBox

Window

VISUELLER BAUM

Page 9: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.
Page 10: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.
Page 11: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

[ContentPropertyAttribute("Items")] [LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)] [StyleTypedPropertyAttribute(Property="ItemContainerStyle", StyleTargetType=typeof(FrameworkElement))] public class ItemsControl : Control, IAddChild

<ListBox> <TextBlock Text="MyTextBlock" /> <Button Content="My Button" /> <Rectangle Width="30" Height="10" Fill="Gray" /> <sys:String>Ein Text!</sys:String> <sys:Random /> </ListBox>

Page 12: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

DEMO...Füllen einer Listbox im XAML-Code

Page 13: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

<Page ...xmlns:sys="clr-namespace:System;assembly=mscorlib"xmlns:sysio="clr-namespace:System.IO;assembly=mscorlib"Margin="10"> <Page.Resources> <ObjectDataProvider ObjectType="{x:Type sysio:DirectoryInfo}" MethodName="GetFiles" x:Key="Files"> <ObjectDataProvider.ConstructorParameters> <sys:String>[...]\Images</sys:String> </ObjectDataProvider.ConstructorParameters> </ObjectDataProvider> </Page.Resources>

<ListBox ItemsSource="{Binding Source={StaticResource Files}}" /></Page>

Page 14: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

DEMO...Füllen einer Listbox mit Data Binding

Page 15: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.
Page 16: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

Resourcen

<ListBox ..."> <ListBox.Resources> <Style TargetType="ListBox"> ... </Style> </ListBox.Resources></ListBox>

Lokale Resourcen

<Page.Resources> <Style TargetType="ListBox"> ... </Style> <Style TargetType="ListBoxItem"> ... </Style></Page.Resources>

Resourcen in Windows oder Pages

<Application.Resources> <Style TargetType="ListBox"> ... </Style> ...</Application.Resources>

Resourcen in app.xaml

Page 17: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

Styles

<ListBox Grid.Column="0" Grid.Row="1"ItemsSource="{Binding Source={StaticResource Files}}"> <ListBox.Resources> <Style TargetType="ListBox"> <Setter Property="Background" Value="LightGray" /> <Setter Property="FontSize" Value="11" /> </Style> </ListBox.Resources></ListBox>

Page 18: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

DEMO...Styling der Listbox

Page 19: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

Templates

FrameworkTemplate

DataTemplateControlTemplat

eItemsPanelTe

mplate

Page 20: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.
Page 21: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

Data Trigger

<DataTemplate DataType="{x:Type sysio:FileInfo}"> ... <DataTemplate.Triggers> <DataTrigger Binding="{Binding Path=IsReadOnly}" Value="True"> <Setter Property="TextBlock.Foreground" Value="Gray" /> <Setter Property="TextBlock.FontStyle" Value="Italic" /> </DataTrigger> </DataTemplate.Triggers></DataTemplate>

Page 22: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

DEMO...Data Template mit Data Trigger

Page 23: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

Control Template

<Style TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Grid> <Ellipse Fill="{StaticResource ButtonBrush}" Stroke="DarkGray" /> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>

Page 24: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

DEMO...Control Template mit Trigger

Page 25: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </ListBox.ItemsPanel>

<TextBlock Text="MyTextBlock" /> <Button Content="My Button" /> <Rectangle Width="30" Height="10" Fill="Gray" /> <sys:String>Ein Text!</sys:String> <sys:Random /> ...</ListBox>

Page 26: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.
Page 27: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

27

DEMO…ListBox mit WrapPanel statt StackPanel

Page 28: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.
Page 29: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

DEMO...ItemsPanelTemplate, individuelles Panel

Page 30: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

Custom Controls

Logik

Design

Page 31: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

DEMO...Custom Control

Page 32: Pimp My Listbox Rainer Stropek cubido business solutions gmbh.

enter the the presentation name in the footer field 32 18.10.2007