Is there a better way to give conditional style in UWP?

I tried to give a conditional style using the converter in style.setter, as shown below,

    <Style TargetType="DataGrid">
        <Setter Property="Background" Value="{Binding Converter={StaticResource cc}}" />
    </Style>

and found out that there is no converter support in UWP. So please suggest me the best way to provide conditional style in UWP using a .setter-style converter

+4
source share
1 answer

No, we do not have support Triggerin UWP.

To save as many triggers as possible from UWP and a Windows 8 phone, they are deleted using msft. We could reach those that use the core of interactivity. Blend (IDE) has great support for creating a trigger in these technologies.

Blend .

  • DataTrigger DataTrigger ,
  • EventTrigger EventTrigger , , .
  • KeyTrigger KeyTrigger , .

. , Windows, , UWP SDK blend

DataTriggerBehavior ChangePropertyAction .

xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" x:Class="XXX_XXXX"

<DataGrid x:Name="MyGrid"
                   Stretch="None"
                   HorizontalAlignment="Stretch" 
                   VerticalAlignment="Top">
  <interactivity:Interaction.Triggers>
   <ec:DataTrigger Binding="{Binding IsBackgroundBlue}" Value="True">
       <ec:ChangePropertyAction TargetObject="{Binding ElementName=MyGrid}" PropertyName="Background" Value="Blue" />
     </ec:DataTrigger>
    <!--  You could add your conditions here />  -->
  </interactivity:Interaction.Triggers>
  </DataGrid>

, . IDE .

fooobar.com/questions/416367/...

Msdn

+3

All Articles