What is the syntax for changing a setter property? RRS feed

  • Question

  • What is the syntax in c++ to change a setter property when clicked a button?

    <Style TargetType="StackPanel" x:Name="answer">
                <Setter Property="Background" Value="LightBlue"/>
                <Setter Property="Margin" Value="55,25,55,25"/>
                <Setter Property="Visibility" Value="Collapsed"/>

    What I'm trying to do is change the visibility value to visible. What is the c++ code for this?
    Thursday, July 18, 2013 10:28 PM


  • I don't think it is possible to change resource properties in the code behind for Windows Store apps.  Only static resources are supported unlike WPF where there are both static and dynamic resources.

    So the alternatives are:

    1. In the button click handler, change the visibility on the StackPanel(s) directly.
    2. Data bind the visibility property of your StackPanels to single boolean property that the button click handler can make true (visible) or false (collapsed).
    Thursday, July 18, 2013 11:48 PM