0

i need to create an instance of a class with two property that would be used as converter parameter of a binding. the class is as below:

public class UnitQuantityBindClass:DependencyObject
{
    public static readonly DependencyProperty QuantityProperty = DependencyProperty.Register(
        "Quantity", typeof(EQuantities), typeof(UnitQuantityBindClass));

    public EQuantities Quantity
    {

        get
        {
            return (EQuantities) GetValue(QuantityProperty);
        }
        set { SetValue(QuantityProperty, value); }
    }

    public static readonly DependencyProperty UnitProperty = DependencyProperty.Register(
        "Unit", typeof(Enum), typeof(UnitQuantityBindClass));

    public Enum Unit
    {
        get { return (Enum)GetValue(UnitProperty); }
        set { SetValue(UnitProperty, value); }
    }
}

the xaml code is as below also:

<textboxunitconvertor:TextBoxUnitConvertor Name="gasDensityValueControl" InstantaneousConvert="True" Margin="96,163,0,0" IsEnabled="{Binding ElementName=chkGas,Path=IsChecked}" QuantityBind="{Binding _FluidBlackOilClass.SGGas_SC.Quantity , RelativeSource={RelativeSource AncestorType=Window}, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"  Width="206" Height="28" HorizontalAlignment="Left" VerticalAlignment="Top">
     <textboxunitconvertor:TextBoxUnitConvertor.TextBoxText>
        <Binding Path="_FluidBlackOilClass.SGGas_SC.Value" RelativeSource="{RelativeSource AncestorType=Window}" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" Converter="{StaticResource ValueStorageForUnitConverter}">
                 <Binding.ConverterParameter>
                     <classes:UnitQuantityBindClass Quantity="{Binding ElementName=gasDensityValueControl,Converter={StaticResource DummyConverter} ,Path=_Quantity,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, PresentationTraceSources.TraceLevel=High}" Unit="{Binding ElementName=gasDensityValueControl,Path=_CurrentUnitEnum,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"></classes:UnitQuantityBindClass>    
                 </Binding.ConverterParameter>
         </Binding>
     </textboxunitconvertor:TextBoxUnitConvertor.TextBoxText>    
     <textboxunitconvertor:TextBoxUnitConvertor.CurrentUnitEnumBind>
         <Binding Source="{StaticResource CurrentFlowProWorkingClass}" Path="currentFlowProWorkingClass.ProjectUnitSystem" UpdateSourceTrigger="PropertyChanged" Mode="OneTime">
            <Binding.ConverterParameter>
                 <classes:UnitQuantityBindClass Quantity="{Binding ElementName=gasDensityValueControl,Path=_Quantity,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Unit="{Binding ElementName=gasDensityValueControl,Path=_CurrentUnitEnum,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"></classes:UnitQuantityBindClass>
             </Binding.ConverterParameter>
         </Binding>
     </textboxunitconvertor:TextBoxUnitConvertor.CurrentUnitEnumBind>
</textboxunitconvertor:TextBoxUnitConvertor>   

but the create class is empty and the Unit and quantity properties does not bind. why?

ganchito55
  • 3,559
  • 4
  • 25
  • 46
ali
  • 63
  • 10
  • "I need to create an instance of a class". Currently, you have two instances, which are assigned to the ConverterParameter properties of the Bindings, but unused otherwise. Instead of that, create a single instance as resource, and access it as StaticResource. – Clemens Dec 10 '16 at 16:10
  • the created instances does not have the unit and quantity of bind properties. why? – ali Dec 11 '16 at 20:59

0 Answers0