开发者

Is it possible to view effects of data triggers in design in Expression Blend 3?

开发者 https://www.devze.com 2022-12-16 09:12 出处:网络
Blend supports displaying the graphical representation of a style resource, and allows you to select an active property/event trigger to view or modify. However, it\'s a common occurrence to have visu

Blend supports displaying the graphical representation of a style resource, and allows you to select an active property/event trigger to view or modify. However, it's a common occurrence to have visual elements controlled by DataTriggers. Is it possible to tell the designer that it should consider a DataTrigger 'active' so that its visual changes can be viewed in the designer?

Example:

<Style x:Key="MyBorder" TargetType="Border">
    <Setter Property="CornerRadius" Value="5" />
    <Style.Triggers>
        <DataTrigger Binding="{Binding IsRandomPropertyActive}" Value="True">
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Color="#FFFF8935" Offset="0" />
                        <GradientStop Color="#FFFF610C" Offset="1" />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
        </DataTrigger>
    </Style.Triggers>
&l开发者_StackOverflow中文版t;/Style>

In the designer, this simply displays an empty box as the default style defines no specific visual aspects. Is there anyway to tell the designer that I want it to assume IsRandomPropertyActive is true, and display the appropriate styling?


If you are using mock ViewModels with Blend, a nice trick is to load your design-time ViewModels from a separate XAML file in the project. If you do this you can easily change the XAML inside Blend and immediately see the changes take effect. For example, you would change your XAML for the mock ViewModel to say:

<AViewModelObject>
  ...
  <AnotherViewModelObject ... IsRandomPropertyActive="true" ... />
  ...
</AViewModelObject>

I am not aware of any simpler way to achieve the functionality you desire.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号