none
How to set bool value to Tag property of the control RRS feed

  • Question

  • Hi All,

    i want to assign bool value i.e. True/False to Tag property of the control through XAML. Is there any way to provide type inofrmation to Tag property.

    I had assigned it like Tag="False", but it is taking as string value, it is not taking as bool value. how to assing bool value to the Tag property? Please let me know if you have any answers for  my question. :)
    Tuesday, June 9, 2009 10:25 AM

Answers

  • You could try explicitly assigning it, assuming you've imported the System namespace with the sys: prefix.

    <Control>
      <Control.Tag>
        <sys:Boolean>False</sys:Boolean>
      </Control.Tag>
    </Control>
    Controls for WPF, Windows Forms and Silverlight at http://www.divelements.co.uk
    • Proposed as answer by decyclone Thursday, June 11, 2009 6:04 AM
    • Marked as answer by Jim Zhou - MSFT Thursday, June 11, 2009 9:49 AM
    Tuesday, June 9, 2009 10:56 AM

All replies

  • You could try explicitly assigning it, assuming you've imported the System namespace with the sys: prefix.

    <Control>
      <Control.Tag>
        <sys:Boolean>False</sys:Boolean>
      </Control.Tag>
    </Control>
    Controls for WPF, Windows Forms and Silverlight at http://www.divelements.co.uk
    • Proposed as answer by decyclone Thursday, June 11, 2009 6:04 AM
    • Marked as answer by Jim Zhou - MSFT Thursday, June 11, 2009 9:49 AM
    Tuesday, June 9, 2009 10:56 AM
  • Thanks. That is working fine.

    But i am facing one more problem. Actually i am creating a trigger where i am validating this Tag property. If i write directly like  below, it is not working.
    <ControlTemplate.Triggers>
                    <Trigger Property="Tag" Value="True">
                        <Setter Property="Content" TargetName="label" Value="Patient View"/>
                    </Trigger>
                    <Trigger Property="Tag" Value="False" >
                        <Setter Property="Content" TargetName="label" Value="Search View"/>
                    </Trigger>
     </ControlTemplate.Triggers>
    How to specify type information here? Please let me know.
    Wednesday, June 10, 2009 3:11 AM
  • Presumably you would do exactly the same thing I showed you before, only with the Trigger.Value property.
    Controls for WPF, Windows Forms and Silverlight at http://www.divelements.co.uk
    Wednesday, June 10, 2009 8:27 AM
  • Thanks . It is working fine.
    Thursday, June 11, 2009 4:42 AM