XAML:访问嵌套控件属性

时间:2012-11-05 15:43:10

标签: xaml

我是否可以访问位于此控件内的网格​​的“背景”属性,以便我可以覆盖需要它的默认图像。

<LocalControls:HeaderedContentControl 
    Style="{StaticResource MultilineHyperlinkStyle}"
    Header="autocompletebox"
    Content="Completion of text based on items"
    />

默认图像在此样式中定义。

<Style TargetType="LocalControls:HeaderedContentControl">
    <Setter Property="HorizontalContentAlignment" Value="Left"/>
    <Setter Property="VerticalContentAlignment" Value="Top"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="LocalControls:HeaderedContentControl">
                <Grid>
                    <Grid.Background>
                        <!-- ::: DEFAULT IMAGE ::: -->
                        <ImageBrush ImageSource="/eSurveyWin7;component/Images/50x50.png" />
                    </Grid.Background>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" MinWidth="50"/>
                        <ColumnDefinition Width="Auto" MinWidth="173"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <ContentPresenter
                        Grid.Column="1"
                        Content="{TemplateBinding Header}"
                        ContentTemplate="{TemplateBinding HeaderTemplate}"
                        Cursor="{TemplateBinding Cursor}"
                        Margin="{TemplateBinding Padding}"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                    <ContentPresenter
                        Grid.Column="1"
                        Grid.Row="1"
                        Content="{TemplateBinding Content}"
                        ContentTemplate="{TemplateBinding ContentTemplate}"
                        Cursor="{TemplateBinding Cursor}"
                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

我只想修改第一个代码段。

0 个答案:

没有答案