Wpf 在XAML上将DependencyProperty绑定到另一个属性时出现问题

Wpf 在XAML上将DependencyProperty绑定到另一个属性时出现问题,wpf,datatemplate,dependency-properties,bind,Wpf,Datatemplate,Dependency Properties,Bind,嗯, 我有一个项目的数据模板: <DataTemplate x:Key="SmallDayEventItemTemplate"> <Border ...> <Grid ...> <TextBlock ... Text="{Binding Path=Title}"/> <my:SmallPl

嗯, 我有一个项目的数据模板:

<DataTemplate x:Key="SmallDayEventItemTemplate">
        <Border ...>
            <Grid ...>

                <TextBlock ...
                        Text="{Binding Path=Title}"/>

                <my:SmallPlayer ...
                        PlayerSource="{Binding Path=MediaSource}">
                </my:SmallPlayer>
             </Grid>
        </Border>
</DataTemplate>
因此,当我在所有者窗口代码中输入一个项目的
MediaSource
时,
item
set
访问器被调用,但是,
SmallPlayer
PlayerSource
set
访问器从未被调用!这是当绑定到
Title
属性的
TextBlock
按预期运行时发生的

Uri uri = null;
if (Uri.TryCreate(mediaName, UriKind.RelativeOrAbsolute, out uri))
       item.MediaSource = uri;

这让我困惑!怎么了?

依赖项属性的CLR包装器永远不能保证被调用,因此不应该包含任何无关逻辑。如果更改依赖项属性时需要额外的逻辑,请使用。具体来说,属性更改了回调。

更准确地说,使用属性更改的回调
Uri uri = null;
if (Uri.TryCreate(mediaName, UriKind.RelativeOrAbsolute, out uri))
       item.MediaSource = uri;