none
VerticalAlignment的DynamicResource要怎么写 RRS feed

  • 问题

  • 请问,我想要这样VerticalAlignment="{DynamicResource lblVerticalAlignment}"

    lblVerticalAlignment要怎么写?

    2013年9月25日 2:34

答案

  • Hi,

      欢迎来到MSDN中文论坛。

      一般定义样式分为资源在内外部定义的不同方式:

     

    1.      内联样式表:即直接设置元素的style属性

    2.      嵌入样式表:即在html页面上写一个<style>……..</style>代码段,然后设置元素的class属性

    3.      外部样式表:即写一个独立的.css文件,然后再html页面上引入该文件,然后设置元素的class属性

      具体你可以参照:http://blog.csdn.net/waitforfree/article/details/8723146 

      你要实际提供给我们你的lblVerticalAlignment要定义成什么样子。

     


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2013年9月27日 6:06
    版主

全部回复

  • Hi,

      欢迎来到MSDN中文论坛。

      一般定义样式分为资源在内外部定义的不同方式:

     

    1.      内联样式表:即直接设置元素的style属性

    2.      嵌入样式表:即在html页面上写一个<style>……..</style>代码段,然后设置元素的class属性

    3.      外部样式表:即写一个独立的.css文件,然后再html页面上引入该文件,然后设置元素的class属性

      具体你可以参照:http://blog.csdn.net/waitforfree/article/details/8723146 

      你要实际提供给我们你的lblVerticalAlignment要定义成什么样子。

     


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2013年9月27日 6:06
    版主
  •     <Style x:Key="WaterMaskBox" TargetType="{x:Type TextBox}">
            <Style.Resources>
                <SolidColorBrush x:Key="WatermaskTextBoxWatermaskForeground" Color="#999999" />
            </Style.Resources>
            <Setter Property="SnapsToDevicePixels" Value="True"/>
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="MinWidth" Value="120"/>
            <Setter Property="MinHeight" Value="20"/>
            <Setter Property="AllowDrop" Value="True"/>
            <Setter Property="Foreground" Value="#FF000000"/>
            <Setter Property="Background" Value="#FFFFFFFF"/>
            <Setter Property="BorderBrush" Value="#FF707070"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TextBox}">
                        <Border x:Name="Border" Padding="2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" >
                            <Grid>
                                <Label x:Name="TextPrompt" Content="{TemplateBinding Tag}" Focusable="False" FontSize="{TemplateBinding FontSize}"   
                                       Foreground="{DynamicResource WatermaskTextBoxWatermaskForeground}" 
                                       Visibility="Collapsed" Padding="0" VerticalContentAlignment="{DynamicResource lblVerticalAlignment}" Margin="10,0,0,0"/>
                                <ScrollViewer Margin="0" x:Name="PART_ContentHost" VerticalAlignment="Center"/>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="Text" Value=""/>
                                </MultiTrigger.Conditions>
                                <Setter Property="Visibility" TargetName="TextPrompt" Value="Visible"/>
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    <TextBox Background="Transparent"  Width="296" Height="44" HorizontalAlignment="Left" Name="txtName" VerticalAlignment="Center"  Tag="帐号" 
                                      Style="{StaticResource WaterMaskBox}" BorderThickness="0" FontSize="16"  Grid.Row="0" Text="{Binding Username}"  >
                                <TextBox.Resources>
                                    <SolidColorBrush x:Key="WatermaskTextBoxWatermaskForeground" Color="#335746" />
                                </TextBox.Resources>
                                </TextBox>

    想要的就是设置对齐方式,只是lblVerticalAlignment怎么像WatermaskTextBoxWatermaskForeground定义
    2013年10月5日 3:05