right Syntax from inside a ComboBox Template to a property of the current Selected Item
Stefan Schmidt
1
Reputation point
Hello,
i ma inside a comboBox Template and try to set a value inside to bind after the Current selectedItem, but missing the right Syntax for that maztter as may possible to write: Typogrpahy.Capitals={Binding Typorgraphy.Capitals, RelativeSoiurce={SelectedItem}}".. Das indeed wrong and not works,, but how to wrtie that ohrase in a right matter?
Here a code example,, the text line i try to get the right syntax is inside the TextBlock element,, marked with two stars
<ComboBox FocusVisualStyle="{x:Null}" Text="C" ToolTipService.ShowDuration="20000" ToolTip="Capitals are a set of typographical forms that render text in capital-styled glyphs.
Typically, when text is rendered as all capitals, the spacing between letters can appear too tight,
and the weight and proportion of the letters too heavy.
OpenType supports a number of styling formats for capitals,
including small capitals, petite capitals, titling, and capital spacing.
These styling formats allow you to control the appearance of capitals." Width="32" Height="32" FontFamily="Palatino Linotype" Grid.IsSharedSizeScope="True" x:Name="FontCapitalsComboBox" Grid.ColumnSpan="2">
<ComboBox.Resources>
<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Border x:Name="Border" BorderThickness="1" BorderBrush="{StaticResource TypographyFieldBorderBrush}" Background="{StaticResource ComboBoxOverlayBrush}">
<Grid x:Name="root" Background="Transparent">
<TextBlock **Typography.CapitalSpacing="{Binding SelectedItem.Typography.CapitalSpacing}"** Foreground="{StaticResource ToogelButtonComboBoxForegroundBrush}" FontSize="24" Padding="0" Text="{TemplateBinding Text}" IsHitTestVisible="False" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBox x:Name="PART_EditableTextBox" Visibility="Collapsed" IsReadOnly="true" />
<Popup x:Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsDropDownOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Slide">
<Grid x:Name="DropDown" SnapsToDevicePixels="True" MinWidth="{TemplateBinding ActualWidth}" MaxHeight="{TemplateBinding MaxDropDownHeight}">
<Border x:Name="DropDownBorder" BorderThickness="1">
<Border.BorderBrush>
<SolidColorBrush Color="{DynamicResource BorderBrushColor}" />
</Border.BorderBrush>
<Border.Background>
<SolidColorBrush Color="{DynamicResource BackgroundColor}" />
</Border.Background>
</Border>
<ScrollViewer Margin="4,6,4,6" SnapsToDevicePixels="True">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained" />
</ScrollViewer>
</Grid>
</Popup>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="ComboBox_PreviewMouseLeftButtonDown"/>
</Style>
</ComboBox.Resources>
<ComboBoxItem Typography.Capitals="Normal" Content="Normal" Tag="Capital letters render normally."/>
<ComboBoxItem Typography.Capitals="SmallCaps" Content="SmallCaps" Tag="Lowercase letters are replaced with a glyph form
of an uppercase letter with the same approximate height."/>
<ComboBoxItem Typography.Capitals="PetiteCaps" Content="PetiteCaps" Tag="Lowercase letters are replaced with a glyph form
of an uppercase letter with the same approximate height.
Petite capitals are smaller than small capitals."/>
<ComboBoxItem Typography.Capitals="AllSmallCaps" Content="AllSmallCaps" Tag="Both capital and lowercase letters are replaced with a glyph
form of an uppercase letter with the same approximate height."/>
<ComboBoxItem Typography.Capitals="AllPetiteCaps" Content="AllPetiteCaps " Tag="Both capital and lowercase letters are replaced with a glyph
form of an uppercase letter with the same approximate height.
Petite capitals are smaller than small capitals."/>
<ComboBoxItem Typography.Capitals="Titling" Content="Titling" Tag="Glyph forms are substituted with a typographic form
specifically designed for titles."/>
<ComboBoxItem Typography.Capitals="Unicase" Content="Unicase" Tag="Capital letters display in unicase. Unicase fonts render both
upper and lowercase letters in a mixture of upper and
lowercase glyphs determined by the type designer."/>
</ComboBox>
Sign in to answer