76 lines
3.7 KiB
XML

<UserControl x:Class="Configuration.View.AddRemoveList"
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"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<ImageSource x:Key="AddIcon">/Assets/Icons/Add.png</ImageSource>
<ImageSource x:Key="DeleteIcon">/Assets/Icons/Delete.png</ImageSource>
<Style x:Key="AddButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Padding" Value="1" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Content">
<Setter.Value>
<Image Source="{StaticResource AddIcon}" Height="15"/>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DeleteButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Padding" Value="1" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Content">
<Setter.Value>
<Image Source="{StaticResource DeleteIcon}" Height="15"/>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0"
SelectionMode="Single"
ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=ListItemsSource, Mode=TwoWay}"
DisplayMemberPath="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=ListDisplayMemberPath}"
SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=SelectedItem,Mode=TwoWay}"
Name="List" />
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Popup Name="AddPopup" IsOpen="{Binding IsChecked, ElementName=AddButton, Mode=TwoWay}">
<Border Background="White" BorderThickness="1" BorderBrush="Black">
<StackPanel Orientation="Horizontal">
<TextBlock>Name</TextBlock>
<TextBox Width="100" Name="AddName"/>
<Button Content="Add"
Click="HideAddPopup"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=AddListItemCommand}"
CommandParameter="{Binding Text, ElementName=AddName}">
</Button>
</StackPanel>
</Border>
</Popup>
<ToggleButton Name="AddButton" Style="{StaticResource AddButtonStyle}"/>
<Button Style="{StaticResource DeleteButtonStyle}" Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=RemoveListItemCommand}" />
</StackPanel>
</Grid>
</UserControl>