<Window xmlns="https://github.com/avaloniaui"
        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" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="LibationAvalonia.Dialogs.EditTemplateDialog"
		xmlns:dialogs="clr-namespace:LibationAvalonia.Dialogs"
		Icon="/Assets/libation.ico"
        Title="EditTemplateDialog">

	<Window.Resources>
		<dialogs:BracketEscapeConverter x:Key="BracketEscapeConverter" />
	</Window.Resources>


	<Grid RowDefinitions="Auto,*,Auto">
		<Grid
			Grid.Row="0"
			RowDefinitions="Auto,Auto"
			ColumnDefinitions="*,Auto" Margin="5">

			<TextBlock
				Grid.Column="0"
				Grid.Row="0"
				Text="{Binding Description}" />

			<TextBox
				Grid.Column="0"
				Grid.Row="1"
				Text="{Binding workingTemplateText, Mode=TwoWay}" />

			<Button
				Grid.Column="1"
				Grid.Row="1"
				Margin="10,0,0,0"
				VerticalAlignment="Stretch"
				Padding="20,3,20,3"
				Content="Reset to Default"
				Click="ResetButton_Click" />
		</Grid>
		<Grid Grid.Row="1" ColumnDefinitions="Auto,*">

			<Border
					Grid.Row="0"
					Grid.Column="0"
					Margin="5"
					BorderThickness="1"
					BorderBrush="{DynamicResource DataGridGridLinesBrush}">

				<DataGrid
					GridLinesVisibility="All"
					AutoGenerateColumns="False"
					Items="{Binding ListItems}" >

					<DataGrid.Columns>

						<DataGridTemplateColumn Width="Auto" Header="Tag">
							<DataGridTemplateColumn.CellTemplate>
								<DataTemplate>
									<TextPresenter Height="18" Margin="10,0,10,0" VerticalAlignment="Center" Text="{Binding TagName, Converter={StaticResource BracketEscapeConverter}}" />
								</DataTemplate>
							</DataGridTemplateColumn.CellTemplate>
						</DataGridTemplateColumn>

						<DataGridTemplateColumn Width="Auto" Header="Description">
							<DataGridTemplateColumn.CellTemplate>
								<DataTemplate>
									<TextPresenter
										Height="18"
										Margin="10,0,10,0"
										VerticalAlignment="Center" Text="{Binding Description}" />
								</DataTemplate>
							</DataGridTemplateColumn.CellTemplate>
						</DataGridTemplateColumn>

					</DataGrid.Columns>
				</DataGrid>

			</Border>


			<Grid
			Grid.Column="1"
			Margin="5"
			RowDefinitions="Auto,*,80" HorizontalAlignment="Stretch">

				<TextBlock
					Margin="5,5,5,10"
					Text="Example:"/>
				
				<Border
					Grid.Row="1"
					Margin="5"
					BorderThickness="1"
					BorderBrush="{DynamicResource DataGridGridLinesBrush}">
					
					<WrapPanel
						Grid.Row="1"
						Name="wrapPanel"
						Orientation="Horizontal" />

				</Border>

				<TextBlock
					Grid.Row="2"
					Margin="5"
					Foreground="Firebrick"
					Text="{Binding WarningText}" />

			</Grid>

		</Grid>
		<Button
			Grid.Row="2"
			Margin="5"
			Padding="30,5,30,5"
			HorizontalAlignment="Right"
			Content="Save"
			Click="SaveButton_Click" />
	</Grid>
</Window>
