Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since you're probably looking to bind the IsEnabled property of the button based on a string, try making a converter for it.</p> <p>Ie... <pre><code> &lt;StackPanel&gt; &lt;StackPanel.Resources&gt; &lt;local:SomeStringConverter mystringtoboolconverter /&gt; &lt;/StackPanel.Resources&gt; &lt;Button IsEnabled="{Binding ElementName=mytree, Path=SelectedItem.Header, Converter={StaticResource mystringtoboolconverter}}" /&gt; &lt;StackPanel&gt; </code></pre></p> <p>and the converter:</p> <pre> <code> [ValueConversion(typeof(string), typeof(bool))] class SomeStringConverter : IValueConverter { public object Convert( object value, Type targetType, object parameter, CultureInfo culture ) { string myheader = (string)value; if(myhead == "something"){ return true; } else { return false; } } public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture ) { return null; } } </code> </pre> <p>EDIT: Since the OP wanted to bind to a variable, something like this needs to be done:</p> <pre> <code> public class SomeClass : INotifyPropertyChanged { private string _somestring; public string SomeString{ get{return _somestring;} set{ _somestring = value; OnPropertyChanged("SomeString");} } public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { if (this.PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } } </code> </pre> <p>Then, change the above binding expression to:</p> <pre> {Binding Path=SomeString, Converter={StaticResource mystringtoboolconverter}} </pre> <p>Note, you MUST implement INotifyPropertyChanged for your UI to be updated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload