<UserControl x:Class="Ion.Sdk.DemoApp.Views.SelectMeasurement"
             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:local="clr-namespace:Ion.Sdk.DemoApp.Views"
             xmlns:ddr="clr-namespace:Ion.Sdk.Ddr;assembly=Ion.Sdk.Ddr"
             xmlns:converters="clr-namespace:Ion.Sdk.DemoApp.Views.Converters"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="300"
             Style="{StaticResource UserControl.Dialog}"
             x:Name="View">
    <UserControl.Resources>
        <converters:InfoToTextConverter x:Key="InfoToTextConverter" />
        <DataTemplate DataType="{x:Type ddr:MeasurementInfo}">
            <Button Style="{StaticResource Button.ListItem}"
                    Cursor="Hand"
                    ToolTip="Click to add measurement"
                    Content="{Binding}"
                    Command="{Binding ElementName=View, Path=AddCommand}"
                    CommandParameter="{Binding}">
                <Button.ContentTemplate>
                    <DataTemplate>
                        <TextBlock Style="{StaticResource TextBlock.Content}"
                                   Foreground="{StaticResource Brush.Accent.Strong}"
                                   Text="{Binding Converter={StaticResource InfoToTextConverter}}"
                                   Margin="{StaticResource Margin.Text}" />
                    </DataTemplate>
                </Button.ContentTemplate>
            </Button>
        </DataTemplate>
    </UserControl.Resources>
    <Grid x:Name="Root">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Border Grid.Row="0"
                Background="{StaticResource Brush.Background}" />
        <Button Grid.Row="0"
                Style="{StaticResource Button.Circle}"
                Command="{Binding ElementName=View, Path=CloseCommand}"
                ContentTemplate="{StaticResource Button.Template.Close}"
                VerticalAlignment="Top"
                HorizontalAlignment="Right"
                Margin="{StaticResource Margin.Button}" />
        <TextBlock Text="Add measurement"
                   Style="{StaticResource TextBlock.Content}"
                   Margin="{StaticResource Margin.Content}"
                   Foreground="{StaticResource Brush.Accent.Strong}" />
        <Grid x:Name="MeasurementsList"
              Grid.Row="1">
            <ScrollViewer Margin="1 0">
                <ItemsControl ItemsSource="{Binding Path=Measurements}" />
            </ScrollViewer>
        </Grid>
    </Grid>
</UserControl>