I want to do something when Idea.Status=="Verified" but QuickConverter (1 - 2) doesn't allow me to use any of these:
Binding="{qc:Binding '$P==Verified',P={Binding Path=Idea.Status}}"
Binding="{qc:Binding '$P=="Verified"',P={Binding Path=Idea.Status}}"
'Verified' is an unexpected token. Expecting white space.
Failed to tokenize expression "$P=Verified". Did you forget a '$'?
How can I tell quickconverter and XAML that I want to compare against a string?
QuickConverter uses single quote for string literals. However within the markup extension you need to escape the single quote, so you need to add \ before it.
So your binding should be
Binding="{qc:Binding '$P==\'Verified\'',P={Binding Path=Idea.Status}}"
I did it this way. It works the same as the chosen answer, but the xaml parser is much happier and doesn't throw annoyng (fake) errors
Binding="{Path=Idea.Status, Converter={qc:QuickConverter '$P == \'Verified\''}}"
The only way i can came up with is by using the qc:MultiBinding
<Grid>
<Button Content="Hi There !" VerticalAlignment=" Center" HorizontalAlignment="Center" IsEnabled="{qc:MultiBinding '$P0 == $P1', P0={Binding Status}, P1={Binding Verified}}"></Button>
</Grid>
Verified
is defined as a property in the ViewModel/CodeBehind
public String Verified { get; set; }
here the full code behind
public partial class MainWindow : Window,INotifyPropertyChanged
{
public String Verified = "Verified";
private String _status = "Verified";
public String Status
{
get
{
return _status;
}
set
{
if (_status == value)
{
return;
}
_status = value;
OnPropertyChanged();
}
}
public MainWindow()
{
InitializeComponent();
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With