Source

main / Source / Excel / Excel.AddIn / Excel.AddIn / View / ErrorPane.xaml

Full commit
<UserControl x:Class="DataUp.Excel.Addin.ErrorPane"
             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" 
             mc:Ignorable="d" 
             xmlns:local="clr-namespace:DataUp.Excel.Addin"
             xmlns:extToolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"
             xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" 
             d:DesignHeight="300" FontFamily="Segoe UI" d:DesignWidth="300" Background="White"  FocusManager.FocusedElement="{Binding ElementName=SheetsListBox}">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/Styles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <BooleanToVisibilityConverter x:Key="VisibilityConverter"></BooleanToVisibilityConverter>

            <local:ErrorPaneViewModel x:Key="Model"/>

            <DataTemplate x:Key="SummayTabItemCountHeader">
                <TextBlock />
            </DataTemplate>

            <DataTemplate x:Key="SheetTabItemCountHeader">
                <TextBlock FontSize="11"><Run Text="("/><Run Text=" "/><Run Text="{Binding TotalErrorCount}"/><Run Text=" "/><Run Text=")"/></TextBlock>
            </DataTemplate>

            <local:ErrorPaneDataTemplateSelector x:Key="HeaderCountTemplateSelector" 
                                                 SheetTemplate="{StaticResource SheetTabItemCountHeader}"
                                                 SummaryTemplate="{StaticResource SummayTabItemCountHeader}" />

            <DataTemplate x:Key="SheetNameTemplate">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="{Binding SheetName}" TextTrimming="CharacterEllipsis" Background="Transparent" ToolTip="{Binding SheetName}"/>
                    <ContentControl Grid.Column="1" Content="{Binding}" ContentTemplateSelector="{StaticResource HeaderCountTemplateSelector}" />
                </Grid>
            </DataTemplate>

            <DataTemplate x:Key="WorkBookItemTemplate">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="30"/>
                        <ColumnDefinition Width="7"/>
                        <ColumnDefinition Width="30"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="5"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Margin="5,-2,0,0" x:Name="lblSheetName" TextTrimming="CharacterEllipsis" 
                           Text="{Binding SheetName}" Style="{DynamicResource LabelStyle}" Width="Auto"  HorizontalAlignment="Left"/>
                    <Button Grid.Column="4" Content="Button"  d:LayoutOverrides="Height" Style="{DynamicResource RoundedButtonStyle}"
                            Command="{Binding Path=SelectSheetCommand, Source={StaticResource Model}}" CommandParameter="{Binding}"/>
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True">
                        <Setter Property="Foreground" Value="White" TargetName="lblSheetName"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <DataTemplate x:Key="SheetDataTemplate">
                <Grid VerticalAlignment="Top" Margin="0,3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="5"/>
                    </Grid.ColumnDefinitions>
                    <CheckBox x:Name="ChkBx" Margin="5,3,0,0" VerticalAlignment="Top"
                              IsChecked="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding IsRemovable}"/>

                    <TextBlock HorizontalAlignment="Left"  Grid.Column="1" Margin="5,0,0,0" VerticalAlignment="Top" x:Name="lblTitle"  TextWrapping="Wrap" TextTrimming="None" Width="Auto" 
                               Text="{Binding Title}" Style="{DynamicResource LabelStyle}" />

                    <Button x:Name="removeBtn" Content="Remove" Grid.Column="2" HorizontalAlignment="Left" Margin="5,0"  VerticalAlignment="Top"
                            d:LayoutOverrides="Height" Style="{DynamicResource CommonButtonStyleSmall}" IsEnabled="{Binding IsRemovable}"
                             Command="{Binding Path=DeleteEntityCommand, Source={StaticResource Model}}" CommandParameter="{Binding}"/>

                    <ToggleButton x:Name="adviceBtn" Tag="{Binding Recommendation}" Content="Advice"  VerticalAlignment="Top"
                                  Style="{DynamicResource CommonToggleButtonStyleSmall}" d:LayoutOverrides="Width, Height" Grid.Column="3" Margin="0,0,5,0"/>

                    <ToggleButton x:Name="InfoButton" Content="ToggleButton" Tag="{Binding Description}"  VerticalAlignment="Top"
                                  Style="{DynamicResource NewInfoToggleButtonStyle}" Grid.Column="4" Width="16" Height="16"/>
                </Grid>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}},Path=IsSelected}" Value="True">
                        <Setter Property="Foreground" Value="White" TargetName="lblTitle"/>
                        <Setter Property="Foreground" Value="White" TargetName="InfoButton"/>
                        <Setter Property="Tag" Value="LighterShade" TargetName="ChkBx"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <ItemsPanelTemplate x:Key="HorizontalPanelTemplate">
                <VirtualizingStackPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>

            <DataTemplate x:Key="ErrorSummaryDataTemplate">
                <ListBox HorizontalContentAlignment="Stretch" Style="{DynamicResource TransparentListBoxStyle}" 
                             ItemTemplate="{DynamicResource WorkBookItemTemplate}" ItemsSource="{Binding Sheets}" 
                             ItemContainerStyle="{DynamicResource RightPaneItemStyle}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"/>

            </DataTemplate>

            <DataTemplate x:Key="ErrorSheetDataTemplate">
                <ListBox HorizontalContentAlignment="Stretch" Style="{DynamicResource TransparentListBoxStyle}" 
                     ItemTemplate="{DynamicResource SheetDataTemplate}" ItemsSource="{Binding Errors}" 
                     ItemContainerStyle="{DynamicResource RightPaneItemStyle}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"/>
            </DataTemplate>

            <local:ErrorPaneDataTemplateSelector x:Key="ErrorTemplateSelector" 
                                                 SheetTemplate="{StaticResource ErrorSheetDataTemplate}"
                                                 SummaryTemplate="{StaticResource ErrorSummaryDataTemplate}" />

            <SolidColorBrush x:Key="ListBorder" Color="#828790"/>

        </ResourceDictionary>

    </UserControl.Resources>

    <UserControl.DataContext>
        <Binding Source="{StaticResource Model}"/>
    </UserControl.DataContext>

    <Grid x:Name="LayoutRoot">
        <extToolkit:BusyIndicator IsBusy="{Binding IsBusy}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Button Content="Remove Selected" HorizontalAlignment="Left" Style="{DynamicResource GrayButtonSmall}" Margin="10,5,0,5"
                        x:Name="btnRemoveSelected" Command="{Binding FixSelectedCommand, Source={StaticResource Model}}" />
                    <ContentControl Style="{DynamicResource HorizontalSeperatorStyle}" VerticalAlignment="Bottom" Grid.Row="1" />
                </Grid>

                <Grid Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="25"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <ListBox Style="{DynamicResource TabListBoxStyleOld}" x:Name="SheetsListBox" ScrollViewer.VerticalScrollBarVisibility="Disabled" 
                     ItemContainerStyle="{DynamicResource RightPaneListItemStyle}" ItemsSource="{Binding Path=SheetDetails}" 
                     IsSynchronizedWithCurrentItem="True" ItemTemplate="{DynamicResource SheetNameTemplate}" SelectedItem="{Binding Path=SelectedSheet, Mode=TwoWay}" />

                    <ContentControl HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1" 
                            Content="{Binding Path=SelectedItem, ElementName=SheetsListBox}" 
                            ContentTemplateSelector="{StaticResource ErrorTemplateSelector}" />
                </Grid>
            </Grid>
        </extToolkit:BusyIndicator>
    </Grid>
</UserControl>