Skip to content

Commit

Permalink
binding extensions: allow for convert parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jtorjo committed Mar 5, 2024
1 parent 034445e commit 54bb5b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Windows.Navigation;
using FastGrid.FastGrid;
using OpenSilver.ControlsKit.FastGrid.DataTemplate;
using OpenSilver.ControlsKit.FastGrid.Util;
using TestRadComboBox;

namespace FastControls.TestApp.Pages
Expand Down Expand Up @@ -144,6 +145,7 @@ private void SecondItemsSource() {
ctrl.Columns[1].Sort = true;
ctrl.AllowMultipleSelection = false;
}

private void Page_Loaded(object sender, RoutedEventArgs e) {
ToggleItemsSource();
}
Expand Down
4 changes: 3 additions & 1 deletion src/FastControls/FastGrid/Util/BindingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace OpenSilver.ControlsKit.FastGrid.Util
public static class BindingExtensions
{
public static T AddBinding<T>(this T fe, DependencyProperty dp, string propertyName, BindingMode mode = BindingMode.OneWay,
object dataContext = null, IValueConverter converter = null, UpdateSourceTrigger updateTrigger = UpdateSourceTrigger.PropertyChanged) where T : FrameworkElement {
object dataContext = null, IValueConverter converter = null, object convertParameter = null, UpdateSourceTrigger updateTrigger = UpdateSourceTrigger.PropertyChanged) where T : FrameworkElement {
var binding = new Binding(propertyName) {
Mode = mode,
UpdateSourceTrigger = updateTrigger,
Expand All @@ -18,6 +18,8 @@ public static T AddBinding<T>(this T fe, DependencyProperty dp, string propertyN
binding.Source = dataContext;
if (converter != null)
binding.Converter = converter;
if (convertParameter != null)
binding.ConverterParameter = convertParameter;
fe.SetBinding(dp, binding);

return fe;
Expand Down

0 comments on commit 54bb5b6

Please sign in to comment.