I have a two columns with buttons in them:
public class GridViewButtonColumn : Telerik.Windows.Controls.GridViewColumn
Based on the data in the row, I need to enable or disable one of those two buttons. So, I have a Boolean value on the row but I haven't figured out how to use that value to bind the IsEnabled property of the button.
Appreciate your help,
Joel
PS. A code example is always welcome.
public class GridViewButtonColumn : Telerik.Windows.Controls.GridViewColumn
Based on the data in the row, I need to enable or disable one of those two buttons. So, I have a Boolean value on the row but I haven't figured out how to use that value to bind the IsEnabled property of the button.
Appreciate your help,
Joel
PS. A code example is always welcome.
public
class
GridViewButtonColumn : Telerik.Windows.Controls.GridViewColumn
{
public
event
ActionRequest ActionRequestEvent;
private
System.Drawing.Bitmap _image =
null
;
public
System.Drawing.Bitmap Image
{
get
{
return
_image;
}
set
{
if
(_image != value)
{
_image = value;
}
}
}
public
GridViewButtonColumn()
{
}
public
GridViewButtonColumn(
System.Drawing.Bitmap image)
{
Image = image;
}
/// <summary>
/// WPF RadGridView Custom Column - Capture & Set Control Properties
/// </summary>
/// <param name="cell"></param>
/// <param name="dataItem"></param>
/// <returns></returns>
public
override
FrameworkElement CreateCellElement(
GridViewCell cell,
object
dataItem)
{
RadButton btn =
new
RadButton()
{
Content =
new
Image()
{
Source = ImageHelper.LoadBitmap(Image)
}
};
btn.Click += btn_Click;
return
btn;
}
void
btn_Click(
object
sender,
RoutedEventArgs e)
{
try
{
ExceptionHelper.TestNull(ActionRequestEvent,
"Button Click Event Handler"
);
Button btn = sender
as
Button;
RadGridView grid = btn.ParentOfType<RadGridView>();
ActionRequestEvent(sender,
new
ActionRequestEventArgs(
new
ContextItem()
{
Control = grid.GetType(),
Action = ProcessAction.Start,
})
{
Data = btn.DataContext,
Sender = grid
});
}
catch
(Exception ex)
{
exceptionHandler(ex);
}
}