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

Binding DependencyProperty value set by code error "0.5 is a bad value"

$
0
0

BOnjour.

hello

I want to set a dependency Property
Brightness( class  BrightContrastEffect)   by code with slider value.

If i use binding it work

But if i write    

Dim ef  = New BrightContrastEffect

ef.Brightness=Slider.Value or  ef.Brightness=0.xx got error  " 0.xx is a bad value" Why ??? I cast to single but do not work

Why?

Merci

Public Class BrightContrastEffect
    Inherits ShaderEffect
    Public Sub New()
        PixelShader = m_shader
        UpdateShaderValue(InputProperty)
        UpdateShaderValue(BrightnessProperty)

        UpdateShaderValue(ContrastProperty)
    End Sub

    Public Property Input() As Brush
        Get
            Return DirectCast(GetValue(InputProperty), Brush)
        End Get
        Set(value As Brush)
            SetValue(InputProperty, value)
        End Set
    End Property

    Public Shared ReadOnly InputProperty As DependencyProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", GetType(BrightContrastEffect), 0) Public Property Brightness() As Single
        Get
            Return CSng(GetValue(BrightnessProperty))
        End Get
        Set(value As Single)
            SetValue(BrightnessProperty, value)
        End Set
    End Property

    Public Shared ReadOnly BrightnessProperty As DependencyProperty = DependencyProperty.Register("Brightness", GetType(Double), GetType(BrightContrastEffect), New UIPropertyMetadata(0.0, PixelShaderConstantCallback(0)))




rt


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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