-
Notifications
You must be signed in to change notification settings - Fork 1
/
SettingsItem.xaml
50 lines (48 loc) · 2.99 KB
/
SettingsItem.xaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<UserControl x:Class="PaperWriting.SettingsItem"
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:PaperWriting"
x:Name="this"
mc:Ignorable="d"
d:DesignHeight="206.145" d:DesignWidth="669.274">
<UserControl.Resources>
<local:SettingOptionValueConverter x:Key="content_converter" />
<DataTemplate x:Key="richtext_tmpl">
<TextBox Grid.Column="1" Grid.Row="0" AcceptsReturn="True" Text="{Binding Path=SettingItemValue,Mode=TwoWay,ElementName=this}"
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" />
</DataTemplate>
<DataTemplate x:Key="text_tmpl">
<TextBox Grid.Column="1" Grid.Row="0" AcceptsReturn="False" Text="{Binding Path=SettingItemValue,Mode=TwoWay,ElementName=this}"
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" />
</DataTemplate>
<DataTemplate x:Key="option_tmpl">
<ComboBox Grid.Column="1" Grid.Row="0" VerticalContentAlignment="Center"
ItemsSource="{Binding Path=SettingItemOptions,ElementName=this}"
SelectedValue="{Binding Path=SettingItemValue,Mode=TwoWay,ElementName=this,Converter={StaticResource content_converter}}" />
</DataTemplate>
<DataTemplate x:Key="check_tmpl">
<CheckBox Grid.Column="1" Grid.Row="0" VerticalContentAlignment="Center"
IsChecked="{Binding Path=SettingItemValue,Mode=TwoWay,ElementName=this}" />
</DataTemplate>
<local:SettingItemSelector x:Key="selector"
TextTmpl="{StaticResource text_tmpl}"
RichTextTmpl="{StaticResource richtext_tmpl}"
OptionTmpl="{StaticResource option_tmpl}"
CheckTmpl="{StaticResource check_tmpl}"/>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" FontFamily="微软雅黑" FontSize="14" Margin="8,0" VerticalAlignment="Top" Text="{Binding SettingItemName}" TextWrapping="Wrap" />
<ContentControl ContentTemplateSelector="{StaticResource selector}" Grid.Column="1" Content="{Binding SettingItemType}" />
<TextBlock Grid.Column="1" Grid.Row="1" FontFamily="微软雅黑" FontSize="10" Foreground="Gray" Text="{Binding SettingItemTip}" TextWrapping="Wrap" />
</Grid>
</UserControl>