开发者

How to trigger "IsRemoteSession" or "IsSoftwareRendering" in UserControl style?

开发者 https://www.devze.com 2023-03-25 03:25 出处:网络
We are developing usercontrols with .NET 4 - WPF. We have a lot of customers who are running our application in a remote session (e.g. Termina开发者_Go百科l-Server, Citriy, etc.).

We are developing usercontrols with .NET 4 - WPF. We have a lot of customers who are running our application in a remote session (e.g. Termina开发者_Go百科l-Server, Citriy, etc.).

Many of the performance issues are already solved. At the moment I'm searching for a way to disable animations in styles and controltemplates depending on the condition of IsRemoteSession and/or IsSoftwareRendering. I will do that without writing a line of code.

I'm pretty sure that I read a blog article some months ago in which it described a way to do that using a trigger in xaml, but I can't find it anymore.

Anyone have any hints....?


The way I would do this is by putting the animations inside the triggers. The code would look something like this:

<Window.Resources>
    <Style TargetType="{x:Type WhateverYourTypeIs}">
    <Style.Triggers>
        <!-- Here I assume your whatever holds your IsRemoteSession property is your DataContext -->
        <!-- Otherwise, change your binding -->
        <DataTrigger Binding="{Binding Path=IsRemoteSession}"
                     Value="False">
            <!-- Here you use Setters to add your animations -->
        </DataTrigger>
    </Style.Triggers>
</Window.Resources>
0

精彩评论

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

关注公众号