<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="OwlCore.Wpf.AbstractUI.Themes.AbstractUIGroupPresenterStyle"
    xmlns:controls="clr-namespace:OwlCore.Wpf.AbstractUI.Controls"
    xmlns:abstractUIVm="clr-namespace:OwlCore.AbstractUI.ViewModels;assembly=OwlCore"
    xmlns:themes="clr-namespace:OwlCore.Wpf.AbstractUI.Themes"
    xmlns:convertvis="clr-namespace:OwlCore.Wpf.Converters.Bools.Visible">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/OwlCore.Wpf;component/AbstractUI/Themes/AbstractUIResources.xaml"/>
        <themes:AbstractBooleanStyle />
        <themes:AbstractButtonStyle />
        <themes:AbstractDataListStyle />
        <themes:AbstractMultiChoiceUIElementStyle />
        <themes:AbstractProgressUIElementStyle />
        <themes:AbstractRichTextBlockStyle />
        <themes:AbstractTextBoxStyle />
    </ResourceDictionary.MergedDictionaries>

    <convertvis:NotNullOrEmptyToVisibilityConverter x:Key="NotNullOrEmptyToVisibilityConverter"/>

    <controls:AbstractUIGroupItemTemplateSelector x:Key="GroupTemplateSelector">
        <controls:AbstractUIGroupItemTemplateSelector.BooleanTemplate>
            <DataTemplate DataType="abstractUIVm:AbstractBooleanViewModel">
                <controls:AbstractBooleanPresenter DataContext="{Binding}" />
            </DataTemplate>
        </controls:AbstractUIGroupItemTemplateSelector.BooleanTemplate>

        <controls:AbstractUIGroupItemTemplateSelector.ButtonTemplate>
            <DataTemplate DataType="abstractUIVm:AbstractButtonViewModel">
                <controls:AbstractButtonPresenter DataContext="{Binding}" />
            </DataTemplate>
        </controls:AbstractUIGroupItemTemplateSelector.ButtonTemplate>

        <controls:AbstractUIGroupItemTemplateSelector.DataListTemplate>
            <DataTemplate DataType="abstractUIVm:AbstractDataListViewModel">
                <controls:AbstractDataListPresenter DataContext="{Binding}" />
            </DataTemplate>
        </controls:AbstractUIGroupItemTemplateSelector.DataListTemplate>

        <controls:AbstractUIGroupItemTemplateSelector.MultiChoiceTemplate>
            <DataTemplate DataType="abstractUIVm:AbstractMultiChoiceViewModel">
                <controls:AbstractMultiChoicePresenter DataContext="{Binding}" />
            </DataTemplate>
        </controls:AbstractUIGroupItemTemplateSelector.MultiChoiceTemplate>

        <controls:AbstractUIGroupItemTemplateSelector.ProgressTemplate>
            <DataTemplate DataType="abstractUIVm:AbstractProgressIndicatorViewModel">
                <controls:AbstractProgessUIElementPresenter DataContext="{Binding}" />
            </DataTemplate>
        </controls:AbstractUIGroupItemTemplateSelector.ProgressTemplate>

        <controls:AbstractUIGroupItemTemplateSelector.TextBoxTemplate>
            <DataTemplate DataType="abstractUIVm:AbstractTextBoxViewModel">
                <controls:AbstractTextBoxPresenter DataContext="{Binding}" />
            </DataTemplate>
        </controls:AbstractUIGroupItemTemplateSelector.TextBoxTemplate>

        <controls:AbstractUIGroupItemTemplateSelector.ElementGroupTemplate>
            <DataTemplate DataType="abstractUIVm:AbstractUICollectionViewModel">
                <controls:AbstractUIGroupPresenter DataContext="{Binding}" />
            </DataTemplate>
        </controls:AbstractUIGroupItemTemplateSelector.ElementGroupTemplate>
    </controls:AbstractUIGroupItemTemplateSelector>

    <DataTemplate x:Key="DefaultAbstractUICollectionTemplate" DataType="abstractUIVm:AbstractUICollectionViewModel">
        <StackPanel Margin="10,20">

            <TextBlock Text="{Binding Title, Mode=OneWay}" FontSize="30" ToolTipService.ToolTip="{Binding TooltipText, Mode=OneWay}" 
                       Visibility="{Binding Path=Title, Converter={StaticResource NotNullOrEmptyToVisibilityConverter}, Mode=OneWay}"/>

            <TextBlock Text="{Binding Subtitle, Mode=OneWay}" FontSize="18" FontWeight="Light" Opacity="0.5"
                       Visibility="{Binding Path=Subtitle, TargetNullValue=Collapsed, Mode=OneWay}"/>

            <ItemsControl ItemsSource="{Binding Items, Mode=OneWay}"
                          ItemTemplateSelector="{StaticResource GroupTemplateSelector}" />
        </StackPanel>
    </DataTemplate>

    <Style TargetType="controls:AbstractUIGroupPresenter">
        <Style.Setters>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="controls:AbstractUIGroupPresenter">
                        <ContentControl  ContentTemplate="{StaticResource DefaultAbstractUICollectionTemplate}"
                                         Content="{TemplateBinding ViewModel}"
                                         DataContext="{TemplateBinding ViewModel}"
                                         HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style.Setters>
    </Style>
    
</ResourceDictionary>
    