Scale a ListBox : ListBox « Windows Presentation Foundation « C# / C Sharp






Scale a ListBox

Scale a ListBox
      
<Window x:Class="WPFTransformations.Scale"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="Scale Transform" Height="400" Width="300"
  >

    <Grid>
        <StackPanel Margin="8">
            <TextBlock Height="25" Width="100"/>

            <ListBox Height="100" Width="200" BorderThickness="2">
                <ListBoxItem Content="Item 1" Height="22"/>
                <ListBoxItem Content="Item 2" Height="22"/>
                <ListBoxItem Content="Item 3" Height="22"/>
                <ListBoxItem Content="Item 4" Height="22"/>
                <ListBox.RenderTransform>
                    <ScaleTransform ScaleX="{Binding Path=Value, ElementName=sliderScaleX}" 
                                    ScaleY="{Binding Path=Value, ElementName=sliderScaleY}"
            CenterX="{Binding Path=Value, ElementName=sliderScaleCX}" 
            CenterY="{Binding Path=Value, ElementName=sliderScaleCY}" 
            />
                </ListBox.RenderTransform>
            </ListBox>

            <TextBlock Height="65" Width="100"/>
            <Grid HorizontalAlignment="Center" Margin="2">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="62" />
                    <ColumnDefinition Width="93"/>
                    <ColumnDefinition Width="16*" />
                </Grid.ColumnDefinitions>

                <TextBlock Text="Scale X:" Margin="0,0,16.323,0" />
                <Slider Name="sliderScaleX" Maximum="2.5" Minimum="0" Value="1" TickFrequency=".1" Grid.ColumnSpan="2" Margin="45.677,0,0,0" />
                <TextBox Grid.Row="0" Grid.Column="2" Text="{Binding Path=Value, ElementName=sliderScaleX}"/>

                <TextBlock Grid.Row="1" Text="Scale Y:" Margin="0,0,16.323,0" />
                <Slider Grid.Row="1" Name="sliderScaleY" Maximum="2.5" Minimum="0" Value="1" TickFrequency=".1" Grid.ColumnSpan="2" Margin="45.677,0,0,0" />
                <TextBox Grid.Row="1" Grid.Column="2" Text="{Binding Path=Value, ElementName=sliderScaleY}"/>

            </Grid>
        </StackPanel>
        <StackPanel Margin="8">
            <TextBlock Height="25" Width="100"/>
            <Rectangle Height="100" Width="200" Stroke="Red" Fill="Red" Opacity=".05"/>
        </StackPanel>
    </Grid>
</Window>

   
    
    
    
    
    
  








Related examples in the same category

1.ListBox With Items PanelListBox With Items Panel
2.Rotate a ListBoxRotate a ListBox
3.Skew Transforms for a ListBoxSkew Transforms for a ListBox
4.ListBoxItem ContentListBoxItem Content
5.ListBox with ImageListBox with Image
6.ListBox with different font for each ListBoxItemListBox with different font for each ListBoxItem
7.Binding ListBox ItemsSource to Fonts.SystemFontFamiliesBinding ListBox ItemsSource to Fonts.SystemFontFamilies
8.ListBox and ListBox.ItemsListBox and ListBox.Items
9.ListBox Leveraging Content PropertyListBox Leveraging Content Property
10.ListBox and SelectionModeListBox and SelectionMode
11.ListBox Selected Index, Item, ValueListBox Selected Index, Item, Value
12.Convert the contents of a ListBoxItem to an instance of GridLength by using GridLengthConverterConvert the contents of a ListBoxItem to an instance of GridLength by using GridLengthConverter
13.Use the FontSizeConverter class to convert the content of a ListBoxItem to a value that represents the size of a font.Use the FontSizeConverter class to convert the content of a ListBoxItem to a value that represents the size of a font.
14.ListBox SelectionChanged EventListBox SelectionChanged Event
15.ListBox SelectionMode=SingleListBox SelectionMode=Single
16.Get Selected Item from ListBoxGet Selected Item from ListBox
17.Display Bounded objects onto ListBoxDisplay Bounded objects onto ListBox
18.Use DataTemplate in ListBoxUse DataTemplate in ListBox
19.Load the Items in a ListBox AsynchronouslyLoad the Items in a ListBox Asynchronously
20.ListBox binds to the people collection, and sets the DataTemplate to use for displaying each item
21.Without specifying a DataTemplate, the ListBox displays a list of names.Without specifying a DataTemplate, the ListBox displays a list of names.
22.ListBox selection changed eventListBox selection changed event
23.Different Font Family and Size for each ListBoxItemDifferent Font Family and Size for each ListBoxItem
24.Handles ListBoxItem Selected events for the ListBoxItems in the inner ListBox.Handles ListBoxItem Selected events for the ListBoxItems in the inner ListBox.
25.Use Panel as a ListBoxItemUse Panel as a ListBoxItem
26.Create a ListBoxItem, set font, content, add the ListBoxItem to the ListBoxCreate a ListBoxItem, set font, content, add the ListBoxItem to the ListBox
27.Select All ListBox ItemsSelect All ListBox Items
28.Create a style that will produce a horizontal ListBox.Create a style that will produce a horizontal ListBox.
29.Convert contents of a ListBoxItem to an instance of Thickness by using the ThicknessConverterConvert contents of a ListBoxItem to an instance of Thickness by using the ThicknessConverter
30.Convert contents of a ListBoxItem to an instance of Thickness by using the BrushConverterConvert contents of a ListBoxItem to an instance of Thickness by using the BrushConverter
31.DataTrigger, ListBox and user objectDataTrigger, ListBox and user object
32.Add selected file to ListBoxAdd selected file to ListBox
33.ListBox with Image itemListBox with Image item
34.Fill up the ListBox with brush namesFill up the ListBox with brush names
35.Get selected item from ListBoxGet selected item from ListBox
36.List box with text and non-text content in the list box items.List box with text and non-text content in the list box items.
37.This list box allows multiple user selections.This list box allows multiple user selections.
38.List box that uses data binding to populate the list box items.List box that uses data binding to populate the list box items.
39.This list box allows items to be selected in groups by using the SHIFT key and mouse or the CTRL key and space key.This list box allows items to be selected in groups by using the SHIFT key and mouse or the CTRL key and space key.
40.Select All and unselect allSelect All and unselect all
41.Get selected item count from ListBoxGet selected item count from ListBox
42.Change the Appearance of Alternate Items in a ListChange the Appearance of Alternate Items in a List
43.Change the Appearance of a List Item When It's SelectedChange the Appearance of a List Item When It's Selected
44.Select Product Page FunctionSelect Product Page Function
45.View and Select Items Using a ListView and Select Items Using a List
46.Set text to TextBlock for selected list itemSet text to TextBlock for selected list item
47.Iterate through the selected items and remove each oneIterate through the selected items and remove each one
48.Ensure there is at least one item selectedEnsure there is at least one item selected