当然,我不想在这个新视图中复制XAML,所以当用户控件是正确的事情吗?
我唯一的问题是,新的DataGrid将被放置在新视图的下面,这样可能吗?而且正如我上面所说的那样,这些列在过滤中可能会有所不同,所以在用户控制中再次有可能出现这种情况?
感谢
解决方案想要创建一个UserControl一种新的UI控件,或者导出一个现有的控件,并增强其功能。
你需要的是一个样式,你想要设置certian属性您对证书价值的控制:
< Style TargetType =Button> < Setter Property =BackgroundValue =Red/> < Setter Property =Template> < Setter.Value> < ControlTemplate TargetType =Button> < Grid> < Rectangle Fill ={TemplateBinding Background/> < ContentPresenter /> < / Grid> < / ControlTemplate> < /Setter.Value> < / Setter> < / Style>
I have a view that Filters a DataGrid and I want to use the the exact same filtering with the same collection (apart from the columns will be different) in a different view.
Of course I dont want to duplicate the XAML in this new view, so is this when a user control would be the correct thing to do?
My only problem is that a new DataGrid will be put underneath in the new view so would this be possible? And as I said above, the columns also may be different in the filtering, so again, possible within a user control?
Thanks
解决方案A UserControl should be used when wanting to create a new kind of control for your UI, or derive an existing control and enhance its capabilities.
What you need sounds like a Style, where you want to set certian properties of your control to certian values:
<Style TargetType="Button"> <Setter Property="Background" Value="Red"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <Grid> <Rectangle Fill="{TemplateBinding Background"/> <ContentPresenter/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
更多推荐
何时在WPF中使用用户控件
发布评论