【发布时间】:2017-07-31 09:16:20
【问题描述】:
我正在开发 UWP 应用程序,我创建了新的用户控件,我想将它绑定到控件代码中的依赖属性(没有数据上下文)。
代码背后:
public Brush Fill
{
get { return (Brush)GetValue(FillProperty); }
set { SetValue(FillProperty, value); }
}
// Using a DependencyProperty as the backing store for Fill. This enables animation, styling, binding, etc...
public static readonly DependencyProperty FillProperty =
DependencyProperty.Register("Fill", typeof(Brush), typeof(MyControl), new PropertyMetadata(new SolidColorBrush(Colors.Black)));
XAML:
...
<Grid>
<Path Fill="{Binding ????}" Stretch="Fill">
...
</Path>
</Grid>
我希望我的路径的填充属性从后面的代码绑定到属性Fill(数据上下文应该保存不同的数据,所以我不能在这里使用它)
如何在 UWP 中做到这一点?
【问题讨论】: