Expression Blend 设计时特定的视觉效果是否可能?

发布于 2024-08-03 10:37:53 字数 930 浏览 4 评论 0原文

我正在尝试在 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="Collapsed" 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幼儿园老大 2024-08-10 10:37:53

嗯,这是一个猜测。

d: 命名空间用于在设计时受到尊重但在运行时被忽略的内容。因此,我们希望在 d: 命名空间内以某种方式设置可见性,它会覆盖运行时设置的可见性。

内联样式会覆盖全局设置或通过 StaticResource 设置的样式,因此我建议这样做(从内存中 - 不要只是复制和粘贴它,而是理解概念):

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

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" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文