[英]WPF Prism, Set several dependency properties of a View (UserControl) from inside Shell
在Prism中,每个View
是一个UserControl
,我有一个View
包含这样的dependency property
(在MyView.xaml.cs
内部):
public int WidgetCornerRadius
{
get { return (int)GetValue(WidgetCornerRadiusProperty); }
set { SetValue(WidgetCornerRadiusProperty, value); }
}
public static readonly DependencyProperty CornerRadiusProperty =
DependencyProperty.Register(
"CornerRadius",
typeof(int),
typeof(MyView),
new UIPropertyMetadata(7));
我展示MyView.xaml
在以下Region
(在Shell.xaml
):
<ContentControl prism:RegionManager.RegionName="TargetRegion"/>
现在我的问题是如何从Shell
内部填充View的CornerRadius
dependency property
? 我需要注册一个新的RegionAdapter
吗? 你可以告诉我如何?
我想要这样的东西:
<ContentControl prism:RegionManager.RegionName="TargetRegion"
CornerRadius="3" />
除了将CornerCorus传递给您的视图之外,您还可以不只是从视图中寻找相关资源来查找该属性吗? 这样应该会容易得多。 假设您有一个依赖于它的边框,那么您要做的就是这样
<Border CornerRadius="{Binding RelativeSource={RelativeSource AncestorType={x:Type HereComesyourType}}, Path=CornerRadius}"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.