Source

main-vinayFork / Source / Excel / Excel.AddIn / Excel.AddIn / View / Usercontrols / Metadata.xaml

Full commit
<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Class="DataUp.Excel.Addin.Metadata"
    x:Name="UserControl" MinWidth="550">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Resources/Styles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <BooleanToVisibilityConverter x:Key="VisibilityConverter"></BooleanToVisibilityConverter>
            <DataTemplate x:Key="MetadataItemTemplate">
                <StackPanel Style="{DynamicResource StackItemPanel}" >
                    <TextBlock Style="{DynamicResource LabelStyle}" Width="250" ToolTip="{Binding Description}">
                       <Run Text="{Binding Name}"/>
                        <Run x:Name="MandatoryText" />
                    </TextBlock>
                    <TextBox x:Name="MetadataTextBox"
                             Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True}"
                             Style="{DynamicResource TextBoxStyle}">
                    </TextBox>
                    <ContentControl IsEnabled="{Binding ElementName=MetadataTextBox,Path=(Validation.HasError),Mode=OneWay}" Style="{DynamicResource ErrorContentControl}" Content="{Binding ElementName=MetadataTextBox ,Path=(Validation.Errors).CurrentItem.ErrorContent}"/>
                </StackPanel>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding IsRequired}" Value="True">
                        <Setter Property="Text" Value="*" TargetName="MandatoryText"/>
                        <Setter Property="Foreground" Value="Red" TargetName="MandatoryText"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <TextBlock Text="Describe your data by completing the metadata fields below. Required fields are designated by a red asterisk." 
                   Style="{DynamicResource DescriptionTextStyle}" Margin="0,10" Foreground="{DynamicResource LabelForeground}"/>

        <TabControl Grid.Row="1" ItemContainerStyle="{DynamicResource ErrorTabItemStyle}" Style="{DynamicResource WizardTabControl}" Tag="ErrorTab" Margin="0,10,0,0">
            <TabItem Header="Data descriptions" Tag="0">

                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Border Grid.Row="0" Padding="10,3" BorderThickness="0,0,0,1" BorderBrush="#FFE6E6E6" SnapsToDevicePixels="True">
                        <StackPanel Orientation="Horizontal" >
                            <Button Margin="0"  Content="CLEAR ALL" Style="{DynamicResource GreenButton}"
                        Command="{Binding ClearAllCommand}"/>
                            <Button Grid.Column="1" Content="RESET" Style="{DynamicResource GreenButton}" 
                        Command="{Binding ResetCommand}" Visibility="Collapsed" />
                        </StackPanel>
                    </Border>
                    <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="1" Margin="{DynamicResource ControlMargin}">
                        <ItemsControl ItemTemplate="{DynamicResource MetadataItemTemplate}" ItemsSource="{Binding MetadataList}"/>
                    </ScrollViewer>
                </Grid>
            </TabItem>
            <TabItem Header="Column descriptions" Tag="0">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Border Padding="10,3" BorderThickness="0,0,0,1" BorderBrush="#FFE6E6E6" 
                            SnapsToDevicePixels="True">
                        <StackPanel Orientation="Horizontal" >
                            <Button Margin="0"  Content="Select Range" Style="{DynamicResource GreenButton}"
                        Command="{Binding GenerateParameterMetadata}"/>
                            <Button Margin="10, 0,0,0"  Content="Add Item" Style="{DynamicResource GreenButton}"
                        Command="{Binding AddNewParameterCommand}"/>
                        </StackPanel>
                    </Border>
                    <DataGrid x:Name="errorGrid" ItemsSource="{Binding ParameterMetadataList}" Style="{DynamicResource DataGridStyle}" 
                              RowBackground="#FFF9F9F9" AlternatingRowBackground="#FFFFFFFF" 
                              CanUserAddRows="False" CanUserDeleteRows="False" IsManipulationEnabled="False" IsReadOnly="False"
                              VerticalGridLinesBrush="{DynamicResource GridVerticalLineBrush}" Grid.Row="1" AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTemplateColumn Width="100" Header="Name">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBox Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ToolTip="{Binding Name}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>

                            <DataGridTemplateColumn Width="200" Header="Description">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBox Text="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ToolTip="{Binding Description}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>

                            <DataGridTemplateColumn Width="100" Header="Type">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <ComboBox SelectedItem="{Binding Type, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                                  ItemsSource="{Binding DataContext.TypeList, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>

                            <DataGridTemplateColumn Width="100" Header="Units">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <ComboBox IsEditable="True" Text="{Binding Units, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding EnableUnits}"
                                                  ItemsSource="{Binding DataContext.StandardUnitsList, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTemplateColumn Width="50">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Style="{DynamicResource CloseMinimizeButtonStyle}" CommandParameter="{Binding}"
                                                Command="{Binding DataContext.DeleteParameterCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</UserControl>