I have a binding in xaml which I would like to delete if some conditions are satisfied at running time. This is a code snippet from my xaml:
<ComboBox x:Name="cbRad" Width="175"
HorizontalAlignment="Left"
cl:FrameworkElementUtil.Required="True"
Height="18"
VerticalAlignment="Top"
TabIndex="20"
DisplayMemberPath="Isotopo" SelectedValue="{Binding Rad}" RenderTransformOrigin="0.247,7.773"
Grid.Row ="6"
Grid.Column="3">
<ComboBox.SelectedItem>
<Binding Path="Rad">
<Binding.ValidationRules>
<v:NotNullValidationRules />
</Binding.ValidationRules>
</Binding>
</ComboBox.SelectedItem>
</ComboBox>
I have investigated about BindingOperations.ClearBinding but all the examples are with Textboxes and I don't really get it. Until now I have tried the following:
BindingOperations.ClearBinding(Me.cbRad,ComboBox.SelectedItem)
Which gives me a compilation error, cause ComboBox.SelectedItem is not an adecuate dependency property.
BindingOperations.ClearBinding(Me.cbRad,Me.cbRad.SelectedItem)
This one compiles but it gives a Runtime error because Me.cbRad.Selecteditem is null.
¿How can I remove the binding as if never was declared using code?