繁体   English   中英

WPF Prism,从Shell内部设置视图(UserControl)的几个依赖项属性

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM