How do you maintain changes made by VisualState triggers after setting another VisualState?

How do you maintain changes made by VisualState triggers after setting another VisualState?

Content Index :

How do you maintain changes made by VisualState triggers after setting another VisualState?
Tag : chash , By : cashshadow
Date : November 27 2020, 09:01 AM

wish of those help The margin of the grid changes to default again because your VisualState are in same VisualStateGroup. You can set the AnimationState in another VisualStateGroup to maintain changes made by the AdaptiveTrigger.
See the Remarks of VisualStateGroup class.
    <VisualStateGroup x:Name="WindowStates">
        <VisualState x:Name="WideLayoutTrigger">
                <AdaptiveTrigger MinWindowWidth="640" />
                <Setter Target="gridNewDrawing.Margin" Value="16" />
    <VisualStateGroup x:Name="OtherStates">
        <VisualState x:Name="AnimationState">
                <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="Cancel" Storyboard.TargetProperty="Visibility">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed" />

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Setting an Initial VisualState in WPF

Tag : wpf , By : marocchino
Date : March 29 2020, 07:55 AM
Hope that helps Too long for a comment
Binding "should" make no difference. If it works fine from code-behind it's bound to work from xaml unless there is something really weird in the Bindings.
<Window ...
<Button x:Name="button"
        Style="{DynamicResource ButtonStyle1}">
      <ei:GoToStateAction StateName="YourState"
                          TargetObject="{Binding ElementName=button}" />

Setting Visibility based on another control's visualstate

Tag : development , By : user152423
Date : March 29 2020, 07:55 AM
seems to work fine I would maintain the ListView selection in a property of the viewmodel and bind Grid.Visibility to that property. You will need an IValueConverter to convert from the selected item's datatype to System.Windows.Visibility, which is required for Grid.Visibility binding.
In case the logic to determine visiblity is more complex, e.g. requires application state, you could add a property bool IsImportantItemSelected to the viewmodel and bind Grid.Visibility to this property. This approach allows you to keep the complex logic in the viewmodel. You'd need an IValueConverter again to convert from bool to System.Windows.Visibility.

Multiple VisualState Triggers for a single Visual State

Tag : chash , By : Ian Badcoe
Date : March 29 2020, 07:55 AM
Any of those help Ok. As there is no built in MultiTrigger, I wrote my own MultiTrigger. The multi trigger supports AND and OR conditions, which is exactly what I needed.
It is now included in the NuGet Package AdaptiveTriggerLibrary.

UWP/WinRT: How to use VisualState Triggers to change the styling of all controls of a certain type?

Tag : development , By : nickthecook
Date : March 29 2020, 07:55 AM
I wish this help you As we've discussed in the comment, your AppBarSeparators are generated in the Pivot's DataTemplate, when controls are placed inside the DateTemplate, they becomes the visual structure of your data objects, but VisualState targets the controls, so can it not work here.
You can use DataBinding with Converter to do this, and if the size of the window is changeable during the run-time, you may also need complete your data source class with INotifyPropertyChanged Interface.
    <local:BoolVisibleConverter x:Key="cvt" />

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Pivot x:Name="docPivot" ItemsSource="{x:Bind pivotlist}" SizeChanged="docPivot_SizeChanged">
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                    <StackPanel Orientation="Horizontal" Grid.Row="0">
                        <AppBarButton Icon="Accept" Label="Accept" />
                        <AppBarSeparator Visibility="{Binding WindowWidth, Converter={StaticResource cvt}}" />
                        <AppBarButton Icon="Cancel" Label="Cancel" />
                        <AppBarButton Icon="Add" Label="Add" />
                        <AppBarSeparator Visibility="{Binding WindowWidth, Converter={StaticResource cvt}}" />
                    <StackPanel Orientation="Horizontal"
private ObservableCollection<MyPivotItem> pivotlist = new ObservableCollection<MyPivotItem>();

public MainPage()

protected override void OnNavigatedTo(NavigationEventArgs e)
    pivotlist.Add(new MyPivotItem { });
    pivotlist.Add(new MyPivotItem { });
    pivotlist.Add(new MyPivotItem { });
    pivotlist.Add(new MyPivotItem { });

private void docPivot_SizeChanged(object sender, SizeChangedEventArgs e)
    foreach (var item in docPivot.Items)
        var pivotitem = item as MyPivotItem;
        pivotitem.WindowWidth = Window.Current.Bounds.Width;
public class MyPivotItem : INotifyPropertyChanged
    public MyPivotItem()
        _windowwidth = Window.Current.Bounds.Width;

    private double _windowwidth;

    public double WindowWidth
        get { return _windowwidth; }
            if (value != _windowwidth)
                _windowwidth = value;

    public event PropertyChangedEventHandler PropertyChanged;

    private void OnPropertyChanged([CallerMemberName] string propertyName = "")
        if (this.PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
public class BoolVisibleConverter : IValueConverter
    public object Convert(object value, Type targetType, object parameter, string language)
        double? width = (double?)value;
        if (width <= 700)
            return Visibility.Collapsed;
        return Visibility.Visible;

    public object ConvertBack(object value, Type targetType, object parameter, string language)
        throw new NotImplementedException();

Setting the initial value of a VisualState

Tag : chash , By : Dov
Date : March 29 2020, 07:55 AM
Hope this helps I think that I have found the answer.
I need to override the function OnApplyTemplate() in my custom control. I have extended the code of the CustomButton class with the following function:
public override void OnApplyTemplate()

  if ( IsChecked )
    VisualStateManager.GoToState(this, "Checked", true);
    VisualStateManager.GoToState(this, "Unchecked", true);
Related Posts Related QUESTIONS :
  • Why does this LinqPad program produce different results on the second run?
  • ServiceStack how to use MaxLoginAttempts feature
  • What does "late-bound access to the destination object" mean?
  • How to load appsettings.json inside a Static class based on deploy environment so that I can use in other class librarie
  • dynamically add images to view
  • Are static extension methods on User object safe?
  • Process thousands of database calls simultaneously
  • Trying to decrypt a string with public key(not private) using bouncycastle in .net
  • How to retrieve the name of an usb device
  • Query many-to-many related data using Entity Framework Core
  • ASP.NET MVC : how to find the view from a controller?
  • Inconsistent behaviour using Entity Framework for ASP.NET MVC app vs windows service
  • AutoFixture Customize vs Build
  • How to change textbox location at the click of a mouse in live mode?
  • How can I deserialize a XML file without defining the parent node?
  • asp.net core how decrease class coupling
  • ASP.NET Core Razor Pages Routing With parameters
  • String Escaping With $ Interpolation and @ Encoding
  • ConfigurationManager in ASP.NET WebAPI tested with HttpServer
  • Top down shooting in Unity 2D don't work as I want it to
  • Use own redirectUri when the Authentication expires
  • Using "foreach" in string array c#
  • "Object reference not set to an instance of an object" for create multiply models on one view
  • Get data passed trought pushAsync
  • Selector expression dynamic on IQueryable
  • Logut with SignInManager not calling method
  • Exit event handler with MessageBox OK button
  • Can not load view from Custom Renderer Xamarin Forms
  • Looking for a .Net ORM
  • Cost of SortedDictionary.Count
  • All possible combinations of n items selected randomly from a set of x items (algorithm)
  • Displaying process percentage on DOS screen
  • C# Importing Large Volume of Data from CSV to Database
  • c# control location precision
  • Printing to Zebra printer gives faint and blurry images
  • How to avoid stepping into dll code file?
  • Programmaticaly prevent Vista desktop search (WDS) from indexing pst files placed on mapped network drives
  • Is there anyway to reduce IsolatedStorage capacity in Silverlight?
  • C#: How to print a unicode string to console?
  • Frequency Table with Random Values
  • My Visual Studio 2008 web application keeps throwing a .Net error when I first run it, but refreshing fixes it
  • TCP Connection Creation and Closing Event Hooking
  • Find changed properties of a class
  • C#: Object with custom marshaller not containing data after PInvoke call
  • Version Control System with API. Need to get metrics
  • Performance comparison of Dictionaries
  • How to get process name and title of the top window on Windows / C#
  • How to save the ListView contents to a text file?
  • Why not .NET-style delegates rather than closures in Java?
  • Get CLSID by PIA interface Type
  • Visual Studio 2008 C# - Recover solution from application manifest possible?
  • Is a good practice to initialize private data members from within ctor by calling the associated properties instead of t
  • Inserting into a bitstream
  • How do you write byte[] array using log4.net
  • Clickonce + .NET client profile 4 framework + offline
  • Show form that showDialog from mainForm won't block it, but closing mainForm will close it
  • Developing a GPS car tracking system
  • dynamic log4net appender name?
  • Visual studio formatting issue
  • IndexOutOfRangeException when a stream is a multiple of the buffer size
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com