表达式是否可以将设计时特定的视觉效果混合? [英] Are Expression Blend design-time specific visuals possible?

查看:172
本文介绍了表达式是否可以将设计时特定的视觉效果混合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Blend 3中设计一些UserControl类。我希望在运行时创建它们中的一部分被折叠,但是我希望能够在每次想要的时候编辑它们的组件而不用代码要构建。



它与样本数据源一起使用,如下例所示。但是它似乎不适用于其他属性...或者我做错了什么?



使用示例数据源SDS_AIVertexAction 我们可以在Expression Blend中执行此操作:

 < UserControl 
xmlns =http://schemas.microsoft.com / winfx / 2006 / xaml / presentation
xmlns:x =http://schemas.microsoft.com/winfx/2006/xaml
xmlns:d =http://schemas.microsoft .com / expression / blend / 2008
xmlns:mc =http://schemas.openxmlformats.org/markup-compatibility/2006
xmlns:local =clr-namespace:WpfApplication1
mc:Ignorable =d
...>


< Grid x:Name =LayoutRoot
d:DataContext ={Binding Source = {StaticResource SDS_AIVertexAction}}>
...
< / Grid>



但似乎没有可以这样做:

 < Label Content ={Binding Name}Visibility =Collapsedd:Visibility = 可见/> 

我意识到我可以改变可见度加载,但我真的不会输入所有的guff每次我做这样的控制。有人知道一个秘密让我们这样做吗?

解决方案

嗯,这是一个猜测。



d:命名空间适用于在设计时遵守但在运行时忽略的东西。所以我们想在d:命名空间中设置可见性,它覆盖了运行时的可见性设置。



内联样式覆盖全局或通过StaticResource设置的样式,所以我建议这样做(从内存中删除 - 不要复制并粘贴它,了解概念):

 < UserControl.Resources> 
< Style x:Key =invisibleTargetType =Label>
< Setter Property =VisibilityValue =Collapsed/>
< / Style>
< /UserControl.Resources>
<! - ... - >
< Label Style ={StaticResource invisible}d:Visibility =Visible/>


I'm trying to design some UserControl classes in Blend 3. I want parts of them to be "collapsed" when created at runtime, but I want to be able to edit their component parts without fiddling with code every time I want to build.

It works with sample datasources, as the following example illustrates. But it doesn't appear to work with other properties... or am I doing something wrong?

With a sample data source SDS_AIVertexAction We can do this in Expression Blend:

<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
...>


<Grid x:Name="LayoutRoot" 
    d:DataContext="{Binding Source={StaticResource SDS_AIVertexAction}}" >
    ...
</Grid>

But it does not seem to be possible to do this:

 <Label Content="{Binding Name}" Visibility="Collapsed" d:Visibility="Visible" />

I realise I could change visibility "on loaded" but I'd really rather not type all that guff every time I make a control like this. Does someone know a secret that lets us do this?

解决方案

Well, here's a guess.

The d: namespace is for stuff that is respected at design time but ignored at runtime. So we want to set the visibility somehow within the d: namespace where it overrides visibility set for runtime.

Inline styles override styles set globally or via StaticResource, so I'd suggest doing this (from memory--don't just copy and paste it, understand the concept):

<UserControl.Resources>
  <Style x:Key="invisible" TargetType="Label">
    <Setter Property="Visibility" Value="Collapsed"/>
  </Style>
</UserControl.Resources>
<!-- ... -->
<Label Style="{StaticResource invisible}" d:Visibility="Visible" />

这篇关于表达式是否可以将设计时特定的视觉效果混合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆