view Chronosv2/source/WidgetLibrary/WidgetLibraryView.xaml @ 21:dfc81f8bb838

working version for sttocks except ui within metrowpf
author adminsh@apollo
date Tue, 20 Mar 2012 15:07:31 +0000
parents 443821e55f06
children
line wrap: on
line source

<chronos:WidgetElement x:Class="Chronos.WidgetLibrary.WidgetLibraryView"
                       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                       xmlns:chronos="http://chronos/schemas/2010/xaml"
                       xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
                       Style="{StaticResource DefaultWidgetStyle}" 
                       Title="Widget Library"
                       mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300">

    <Grid Background="Transparent" Margin="5,5,5,5">
        <Grid.Resources>
            <CollectionViewSource x:Key="WidgetsViewSource" 
                                  Source="{Binding Widgets, Mode=OneWay}">
                <CollectionViewSource.GroupDescriptions>
                    <PropertyGroupDescription PropertyName="Group" StringComparison="OrdinalIgnoreCase" />
                </CollectionViewSource.GroupDescriptions>
                <CollectionViewSource.SortDescriptions>
                    <scm:SortDescription PropertyName="Group"/>
                </CollectionViewSource.SortDescriptions>
            </CollectionViewSource>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <ComboBox ItemsSource="{Binding Groups, Mode=OneWay}"
                      IsSynchronizedWithCurrentItem="True"
                      SelectedValue="{Binding Path=Filter, Mode=TwoWay}"
                      HorizontalAlignment="Stretch" VerticalAlignment="Center">
            </ComboBox>
        </Grid>

        <Grid Grid.Row="1" Margin="0,3.5,0,0">
            <ListBox x:Name="WidgetLibraryList"
                     chronos:DragDropManager.IsDragSource="True"
                     Background="Transparent"
                     IsSynchronizedWithCurrentItem="True"
                     VerticalAlignment="Stretch"
                     ItemsSource="{Binding Source={StaticResource WidgetsViewSource}}" 
                     SelectedItem="{Binding SelectedWidget, Mode=TwoWay}"
                     AllowDrop="False"
                     ScrollViewer.HorizontalScrollBarVisibility="Hidden">

                <ListBox.ItemTemplate>
                    <DataTemplate DataType="{x:Type chronos:WidgetViewModel}">
                        <ContentControl Margin="3.5" HorizontalContentAlignment="Stretch" Background="Transparent">
                            <ContentControl.InputBindings>
                                <MouseBinding MouseAction="LeftDoubleClick" Command="{Binding CreateWidgetCommand}"/>
                            </ContentControl.InputBindings>

                            <StackPanel HorizontalAlignment="Left" VerticalAlignment="Center">
                                <TextBlock Text="{Binding Title}" 
                                           FontSize="{StaticResource ControlTitleFontSize}" FontWeight="Light"/>

                                <TextBlock Text="{Binding Description}"
                                           TextWrapping="Wrap"/>
                            </StackPanel>
                        </ContentControl>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>

        <Grid Grid.Row="2">
            <Button Content="Add to Desktop" Command="{Binding CreateWidgetCommand}" HorizontalAlignment="Right" />
        </Grid>
    </Grid>
</chronos:WidgetElement>