<commit_before>﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:s="clr-namespace:System;assembly=mscorlib"
    xmlns:xu="clr-namespace:Cube.Xui"
    xmlns:xb="clr-namespace:Cube.Xui.Behaviors"
    xmlns:my="clr-namespace:Cube.Net.App.Rss.Reader">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Themes/RssComponents.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <!--
        Customize for TreeViewItem
    -->
    
    <Style TargetType="TreeViewItem" BasedOn="{StaticResource {x:Type TreeViewItem}}">
        <Setter Property="IsExpanded" Value="{Binding Expanded, Mode=TwoWay}"/>
        <Setter Property="IsSelected" Value="{Binding Selected, Mode=TwoWay}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TreeViewItem">
                    <Grid HorizontalAlignment="Stretch">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Border
                            x:Name="Bd"
                            Background="Transparent"
                            BorderThickness="0"
                            Padding="20,0,0,0"
                            BorderBrush="Transparent"
                            SnapsToDevicePixels="True">
                            <ContentPresenter
                                x:Name="PART_Header"
                                Content="{TemplateBinding HeaderedContentControl.Header}"
                                ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}"
                                ContentStringFormat="{TemplateBinding HeaderedItemsControl.HeaderStringFormat}"
                                ContentSource="Header"
                                HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
                                SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"/>
                        </Border>
                        <ItemsPresenter Name="ItemsHost" Grid.Row="1"/>
                    </Grid>
                    
                    <ControlTemplate.Triggers>
                        <Trigger Property="TreeViewItem.IsExpanded">
                            <Setter TargetName="ItemsHost" Property="UIElement.Visibility" Value="{x:Static Visibility.Collapsed}"/>
                            <Trigger.Value>
                                <s:Boolean>False</s:Boolean>
                            </Trigger.Value>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel IsItemsHost="True" Margin="20,0,0,0"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--
        ToolTip for RSS entry
    -->
    
    <ToolTip x:Key="RssEntryToolTip">
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding Title}"/>
            <TextBlock Text="{Binding Count, StringFormat=' ({0})'}"/>
        </StackPanel>
    </ToolTip>
    
    <!--
        TreeViewItem for RssCategory
    -->

    <ControlTemplate x:Key="RssCategoryTemplate">
        <Grid ToolTip="{StaticResource RssEntryToolTip}" Cursor="Hand" Margin="2,2,0,2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <TextBlock
                Text="{Binding Expanded, Converter={my:ExpandConverter}}"
                Style="{StaticResource SymbolStyle}"
                Margin="0,4,6,0"
                Grid.Column="0"/>
            <TextBlock
                Text="{Binding Title}"
                Style="{StaticResource RssCategoryStyle}"
                Grid.Column="1"/>
            <TextBlock
                Text="{Binding Count, StringFormat=({0})}"
                Style="{StaticResource RssCategoryStyle}"
                Grid.Column="2"/>

            <TextBox
                Text="{Binding Title, UpdateSourceTrigger=LostFocus}"
                Style="{StaticResource RssEditEntryStyle}"
                Visibility="Collapsed"
                Grid.Column="1">
                <i:Interaction.Behaviors>
                    <xb:EditMode Value="{Binding Editing, Mode=TwoWay}"/>
                </i:Interaction.Behaviors>
            </TextBox>

            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseDown">
                    <i:InvokeCommandAction
                        Command="{Binding DataContext.SelectEntry, ElementName=Root}"
                        CommandParameter="{Binding}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Grid>
    </ControlTemplate>
    
    <HierarchicalDataTemplate DataType="{x:Type my:RssCategory}" ItemsSource="{Binding Children}">
        <CheckBox
            IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType=TreeViewItem}}"
            Template="{StaticResource RssCategoryTemplate}"/>
    </HierarchicalDataTemplate>

    <!--
        TreeViewItem for RssEntry
    -->
    
    <HierarchicalDataTemplate DataType="{x:Type my:RssEntry}">
        <Grid ToolTip="{StaticResource RssEntryToolTip}" Cursor="Hand" Margin="2,0,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            
            <TextBlock
                Text="&#xe903;"
                Style="{StaticResource SymbolStyle}"
                Margin="0,4,6,0"
                Grid.Column="0"/>
            <TextBlock
                Text="{Binding Title}"
                Style="{StaticResource RssEntryStyle}"
                Grid.Column="1"/>
            <TextBlock
                Text="{Binding Count, StringFormat=({0})}"
                Style="{StaticResource RssEntryStyle}"
                Grid.Column="2"/>

            <TextBox
                Text="{Binding Title, UpdateSourceTrigger=LostFocus}"
                Style="{StaticResource RssEditEntryStyle}"
                Visibility="Collapsed"
                Grid.Column="1">
                <i:Interaction.Behaviors>
                    <xb:EditMode Value="{Binding Editing, Mode=TwoWay}"/>
                </i:Interaction.Behaviors>
            </TextBox>

            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseDown">
                    <i:InvokeCommandAction
                        Command="{Binding DataContext.SelectEntry, ElementName=Root}"
                        CommandParameter="{Binding}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Grid>
    </HierarchicalDataTemplate>
</ResourceDictionary><commit_msg>Fix for binding Selected property.<commit_after>﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:s="clr-namespace:System;assembly=mscorlib"
    xmlns:xu="clr-namespace:Cube.Xui"
    xmlns:xb="clr-namespace:Cube.Xui.Behaviors"
    xmlns:my="clr-namespace:Cube.Net.App.Rss.Reader">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Themes/RssComponents.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <!--
        Customize for TreeViewItem
    -->
    
    <Style TargetType="TreeViewItem" BasedOn="{StaticResource {x:Type TreeViewItem}}">
        <Setter Property="IsExpanded" Value="{Binding Expanded, Mode=TwoWay}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="TreeViewItem">
                    <Grid HorizontalAlignment="Stretch">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Border
                            x:Name="Bd"
                            Background="Transparent"
                            BorderThickness="0"
                            Padding="20,0,0,0"
                            BorderBrush="Transparent"
                            SnapsToDevicePixels="True">
                            <ContentPresenter
                                x:Name="PART_Header"
                                Content="{TemplateBinding HeaderedContentControl.Header}"
                                ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}"
                                ContentStringFormat="{TemplateBinding HeaderedItemsControl.HeaderStringFormat}"
                                ContentSource="Header"
                                HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
                                SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"/>
                        </Border>
                        <ItemsPresenter Name="ItemsHost" Grid.Row="1"/>
                    </Grid>
                    
                    <ControlTemplate.Triggers>
                        <Trigger Property="TreeViewItem.IsExpanded">
                            <Setter TargetName="ItemsHost" Property="UIElement.Visibility" Value="{x:Static Visibility.Collapsed}"/>
                            <Trigger.Value>
                                <s:Boolean>False</s:Boolean>
                            </Trigger.Value>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel IsItemsHost="True" Margin="20,0,0,0"/>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--
        ToolTip for RSS entry
    -->
    
    <ToolTip x:Key="RssEntryToolTip">
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding Title}"/>
            <TextBlock Text="{Binding Count, StringFormat=' ({0})'}"/>
        </StackPanel>
    </ToolTip>
    
    <!--
        TreeViewItem for RssCategory
    -->

    <ControlTemplate x:Key="RssCategoryTemplate">
        <Grid ToolTip="{StaticResource RssEntryToolTip}" Cursor="Hand" Margin="2,2,0,2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <TextBlock
                Text="{Binding Expanded, Converter={my:ExpandConverter}}"
                Style="{StaticResource SymbolStyle}"
                Margin="0,4,6,0"
                Grid.Column="0"/>
            <TextBlock
                Text="{Binding Title}"
                Style="{StaticResource RssCategoryStyle}"
                Grid.Column="1"/>
            <TextBlock
                Text="{Binding Count, StringFormat=({0})}"
                Style="{StaticResource RssCategoryStyle}"
                Grid.Column="2"/>

            <TextBox
                Text="{Binding Title, UpdateSourceTrigger=LostFocus}"
                Style="{StaticResource RssEditEntryStyle}"
                Visibility="Collapsed"
                Grid.Column="1">
                <i:Interaction.Behaviors>
                    <xb:EditMode Value="{Binding Editing, Mode=TwoWay}"/>
                </i:Interaction.Behaviors>
            </TextBox>

            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseDown">
                    <i:InvokeCommandAction
                        Command="{Binding DataContext.SelectEntry, ElementName=Root}"
                        CommandParameter="{Binding}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Grid>
    </ControlTemplate>
    
    <HierarchicalDataTemplate DataType="{x:Type my:RssCategory}" ItemsSource="{Binding Children}">
        <CheckBox
            IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource AncestorType=TreeViewItem}}"
            Template="{StaticResource RssCategoryTemplate}"/>
    </HierarchicalDataTemplate>

    <!--
        TreeViewItem for RssEntry
    -->

    <ControlTemplate x:Key="RssEntryTemplate">
        <Grid ToolTip="{StaticResource RssEntryToolTip}" Cursor="Hand" Margin="2,0,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <TextBlock
                Text="&#xe903;"
                Style="{StaticResource SymbolStyle}"
                Margin="0,4,6,0"
                Grid.Column="0"/>
            <TextBlock
                Text="{Binding Title}"
                Style="{StaticResource RssEntryStyle}"
                Grid.Column="1"/>
            <TextBlock
                Text="{Binding Count, StringFormat=({0})}"
                Style="{StaticResource RssEntryStyle}"
                Grid.Column="2"/>

            <TextBox
                Text="{Binding Title, UpdateSourceTrigger=LostFocus}"
                Style="{StaticResource RssEditEntryStyle}"
                Visibility="Collapsed"
                Grid.Column="1">
                <i:Interaction.Behaviors>
                    <xb:EditMode Value="{Binding Editing, Mode=TwoWay}"/>
                </i:Interaction.Behaviors>
            </TextBox>

            <i:Interaction.Triggers>
                <i:EventTrigger EventName="MouseDown">
                    <i:InvokeCommandAction
                        Command="{Binding DataContext.SelectEntry, ElementName=Root}"
                        CommandParameter="{Binding}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Grid>
    </ControlTemplate>

    <HierarchicalDataTemplate DataType="{x:Type my:RssEntry}">
        <RadioButton
            GroupName="RssEntryGroup"
            IsChecked="{Binding Selected}"
            Template="{StaticResource RssEntryTemplate}"/>
    </HierarchicalDataTemplate>
</ResourceDictionary>
{'fraction_non_alphanumeric': 0.11432185897862707, 'fraction_numerical': 0.007190891537385977, 'mean_word_length': 1.636938202247191, 'pattern_counts': {'":': 0, '<': 201, '<?xml version=': 0, '>': 201, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3136870', 'n_tokens_mistral': 3898, 'n_tokens_neox': 3529, 'n_words': 521}