I would make it custom control,make a trigger for it at Property =isEnabled value=false. Over the image,I would add a grid with some oppacity,and control that oppacity or visibility with that trigger. Good luck.
I don't think there is an easier way.
Up vote 0 down vote favorite share g+ share fb share tw.
I have created an UserControl to implement a simple ImageButton as following: Here is code-behind of my control: using System. Windows; using System.Windows. Controls; using System.Windows.
Input; using System.Windows. Media; namespace MyApp.Common. Controls { public partial class ImageButton : UserControl { public ImageButton() { InitializeComponent(); } public ImageSource Image { get { return (ImageSource)GetValue(ImageProperty); } set { SetValue(ImageProperty, value); } } public static readonly DependencyProperty ImageProperty = DependencyProperty.
Register("Image", typeof(ImageSource), typeof(ImageButton), new UIPropertyMetadata(null)); public double ImageWidth { get { return (double)GetValue(ImageWidthProperty); } set { SetValue(ImageWidthProperty, value); } } public static readonly DependencyProperty ImageWidthProperty = DependencyProperty. Register("ImageWidth", typeof(double), typeof(ImageButton), new UIPropertyMetadata(16d)); public double ImageHeight { get { return (double)GetValue(ImageHeightProperty); } set { SetValue(ImageHeightProperty, value); } } public static readonly DependencyProperty ImageHeightProperty = DependencyProperty. Register("ImageHeight", typeof(double), typeof(ImageButton), new UIPropertyMetadata(16d)); public string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } public static readonly DependencyProperty TextProperty = DependencyProperty.
Register("Text", typeof(string), typeof(ImageButton), new UIPropertyMetadata("")); public ICommand Command { get { return (ICommand)GetValue(CommandProperty); } set { SetValue(CommandProperty, value); } } public static readonly DependencyProperty CommandProperty = DependencyProperty. Register("Command", typeof(ICommand), typeof(ImageButton)); public object CommandParameter { get { return GetValue(CommandParameterProperty); } set { SetValue(CommandParameterProperty, value); } } public static readonly DependencyProperty CommandParameterProperty = DependencyProperty. Register("CommandParameter", typeof(object), typeof(ImageButton)); } } The usage is simple: When the button (bound to DelegateCommand in my ViewModel) get disabled the image is disappear.
Otherwise all works as expected. What could be a problem? How to make the image show in gray-scale when disabled?
C# wpf visual-studio-2010 xaml wpf-usercontrols link|improve this question edited 4 hours ago asked 4 hours agoMichael D.12511 100% accept rate.
I copied the code that you had provided to see if I could reproduce the problem you were having. Unfortunately, when the command was disabled (or it's CanExecute was returning false) the image I used did not disappear. Could you please provide more code from your ViewModel that you think may be relevant?
To answer the second part of your question: How to make the image show in gray-scale when disabled? As far as I know there is no easy way to desaturate an image in WPF. Instead, I would go with the approach that @Vova had suggested which is to lower the Opacity property of the Image.
You can modify your UserControl XAML you provided like so: In the code above I added a DataTrigger to the Image's Style property to modify the opacity of the image if the IsEnabled property of the button is equal to false. Hope this helps!
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.