Просто таблица из 3-ех столбцов.
Я пытался найти, как задать расстояние между строками и столбцами таблицы, но не нашел.
Можно ли это как-то сделать через стили, чтобы руками у каждого элемента не прописывать?
Я нашел вот такое решение, но что-то оно у меня не работает...
<Style TargetType="Border" >
<Setter Property="Padding" Value="10,10,10,10" />
</Style>
Пример разметки, но я тут уже руками успел прописать везде Margin...
<Window x:Class="DictionaryCreator.UI.Windows.SourceConfigurationWindow"
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"
xmlns:local="clr-namespace:DictionaryCreator.UI.Windows"
mc:Ignorable="d"
Title="Конфигурация источника" Height="420" Width="800">
<Grid>
<Grid.Resources >
<Style TargetType="Border" >
<Setter Property="Margin" Value="500" />
</Style>
<Style TargetType="Image" >
<Setter Property="Height" Value="30" />
<Setter Property="Width" Value="30" />
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" ></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Label Margin="5" Grid.Row="0" Grid.Column="0" HorizontalContentAlignment="Right">Тип базы данных</Label>
<ComboBox Margin="5" Grid.Row="0" Grid.Column="1" ItemsSource="{Binding Path=DbKinds}" DisplayMemberPath="Name" SelectedValue="{Binding Path=SelectedDbKind}"></ComboBox>
<Label Grid.Row="1" Grid.Column="0" Margin="5" HorizontalContentAlignment="Right">Сервер (MSSQL) или путь к файлу (MS ACCESS)</Label>
<TextBox Grid.Row="1" Grid.Column="1" Margin="5" Text="{Binding Path=FilePathOrServerName,UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Label Grid.Row="2" Grid.Column="0" Margin="5" HorizontalContentAlignment="Right">Название базы данных</Label>
<TextBox Grid.Row="2" Grid.Column="1" Margin="5" IsEnabled="{Binding Path=DbNameEnable}" Text="{Binding Path=DbName,UpdateSourceTrigger=PropertyChanged}"></TextBox>
<Label Grid.Row="3" Margin="5" HorizontalContentAlignment="Right">Название таблицы</Label>
<Grid Grid.Row="3" Grid.Column="1" Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0" DockPanel.Dock="Left" MinWidth="300" ItemsSource="{Binding Path=TableDescriptions}" SelectedValue="{Binding Path=SelectedTableDescription}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock>
<Run Text="{Binding Schema}" />
<Run Text="." />
<Run Text="{Binding TableName}" />
</TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
<Button Grid.Row="3" Grid.Column="2" Margin="5" DockPanel.Dock="Right" Command="{Binding Path=RefreshTablesCommand}" >
<Image Width="30" Height="20" Source="../Icons/Refresh.png"/>
<Button.ToolTip>
Обновить
</Button.ToolTip>
</Button>
<Label Grid.Row="4" HorizontalContentAlignment="Right" Margin="5">Ключ таблицы (целое число)</Label>
<ComboBox Grid.Row="4" Grid.Column="1" Margin="5" ItemsSource="{Binding Path=ColumnDescriptions}" DisplayMemberPath="ColumnName" SelectedValue="{Binding Path=SelectedKeyColumnDescription}"></ComboBox>
<Label Grid.Row="5" Margin="5" HorizontalContentAlignment="Right">Поле нормализуемого значения</Label>
<ComboBox Grid.Row="5" Margin="5" Grid.Column="1" ItemsSource="{Binding Path=ColumnDescriptions}" DisplayMemberPath="ColumnName" SelectedValue="{Binding Path=SelectedValueColumnDescription}"></ComboBox>
<Label Grid.Row="6" Margin="5" HorizontalContentAlignment="Right">Идентификатор привязки к справочнику</Label>
<ComboBox Grid.Row="6" Margin="5" Grid.Column="1" ItemsSource="{Binding Path=ColumnDescriptions}" DisplayMemberPath="ColumnName" SelectedValue="{Binding Path=SelectedDictKeyColumnDescription}"></ComboBox>
<WrapPanel Grid.Row="7" Grid.ColumnSpan="3" HorizontalAlignment="Center" Margin="0 30 0 0">
<Button Margin="0 0 25 0"
Command="{Binding Path=SaveCommand}">
<Button.Content>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
<Image Margin="5 0 0 0" Source="../Icons/Save.png"/>
<Label>Сохранить</Label>
</StackPanel>
</Button.Content>
</Button>
<Button Margin="0 0 25 0"
Command="{Binding Path=CancelCommand}">
<Button.Content>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
<Image Margin="5 0 0 0" Source="../Icons/Cancel.png"/>
<Label>Отменить</Label>
</StackPanel>
</Button.Content>
</Button>
</WrapPanel>
</Grid>
</Window>
<Setter Property="Margin" Value="5" />
или<Setter Property="Margin" Value="5,5,5,5" />
, что в принципе одно и то же.<Border>
, к которому вы пытаетесь применить стиль.