Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>
</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?

like image 924
jeffora Avatar asked Nov 06 '22 17:11

jeffora


1 Answers

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.

like image 75
Ray Burns Avatar answered Nov 10 '22 01:11

Ray Burns