WPF样式表和绑定

时间:2014-05-02 18:07:33

标签: wpf vb.net xaml data-binding

我有一个样式表,我想在不同的自定义控件上使用。 例 的 Stylesheet.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <Style x:Key="ExampleProgressBar" TargetType="ProgressBar">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ProgressBar">
                    <Border DataContext="{Binding RelativeSource={RelativeSource Self}}" Background="{Binding Path=Example_BG}">
                        <Grid x:Name="PART_Track" >
                            <Rectangle x:Name="PART_Indicator" HorizontalAlignment="Left" Fill="#FF1B9AF1" RadiusX="5" RadiusY="5"/>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

当我在样式表上使用上面的内容时,它不会绑定到自定义控件....

无论如何都要绑定样式表样式以使用许多自定义控件吗?

0 个答案:

没有答案