Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

DataGridTextColumn MultiBinding with ElementName works not all machines - DependencyProperty.UnsetValue

$
0
0

Today, I got a crazy behaviour. My multibinding works on one machine but on another I got DependencyProperty.UnsetValue. 

Machine 1:

Win8 works fine

Machine 2:

Win7 got DependencyProperty.UnsetValue

Here is my XAML:

<StackPanel Margin="10" Orientation="Horizontal"><TextBlock VerticalAlignment="Center" Margin="10" Text="Steuer: " /><ComboBox Name="ComboSteuer" ItemsSource="{Binding Steuern}" SelectedIndex="0" HorizontalContentAlignment="Stretch"  Width="100" Margin="10" /></StackPanel><DataGrid
            SelectionMode="Extended"
            SelectionUnit="FullRow"
            RowHeaderWidth="0"
            IsReadOnly="True"
            ItemsSource="{Binding Books}"
            AutoGenerateColumns="False"><DataGrid.Columns><DataGridTextColumn Header="Title" Binding="{Binding Title}" Width="*" /><DataGridTextColumn Header="Autor" Binding="{Binding Author}" Width="*" /><DataGridTextColumn Header="Netto" Binding="{Binding NetPrice, StringFormat=' {0} €'}" Width="Auto" /><DataGridTextColumn Header="Steuer"><DataGridTextColumn.Binding><MultiBinding StringFormat=' {0:f} €' Converter="{multiDataBindingSample:SteuerConverter}"><Binding ElementName="ComboSteuer" Path="SelectedValue" /><Binding Path="NetPrice" /></MultiBinding></DataGridTextColumn.Binding></DataGridTextColumn>

And my converer for the MultiBinding looks:

 public class SteuerConverter : MarkupExtension, IMultiValueConverter
    {
        private SteuerConverter _bruttoConverter;

        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            double steuer =0;
            if (Double.TryParse(values[0].ToString(), out steuer))
            {
                double netto = Double.Parse(values[1].ToString());

                return netto/100*steuer;
            }

            
            return values[1];
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            return default(object[]);
        }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return _bruttoConverter ?? (_bruttoConverter = new SteuerConverter());
        }
    }

I know the could could be nicer ;-)

Machine 2 with Win7

Machine 1 with Win8

Framework is 4.0. Some help would be nice.

Kind Regards,

Dany


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>