WPF Binding – Default value for empty string

DataTrigger is the way i do it like this: <TextBox> <TextBox.Style> <Style TargetType=”{x:Type TextBox}” BasedOn=”{StaticResource ReadOnlyTextBox}”> <Setter Property=”Text” Value=”{Binding Name}”/> <Style.Triggers> <DataTrigger Binding=”{Binding Path=Name.Length, FallbackValue=0, TargetNullValue=0}” Value=”0″> <Setter Property=”Text” Value=”{x:Static local:ApplicationLabels.NoValueMessage}”/> </DataTrigger> </Style.Triggers> </Style> </TextBox.Style> </TextBox>

Assembly binding redirect does not work

Any typo in configuration xml can be a cause. Loader just can’t see your configuration. I also had a hour of headache until I realize that the error was in character “=” instead of “-” in schema name: <assemblyBinding xmlns=”urn:schemas=microsoft-com:asm.v1″> Just check carefully all attribute names and values. I guess “PublicKeyToken” should be “publicKeyToken” This … Read more

Binding property to control in Winforms

You must implement INotifyPropertyChanged And add binding to textbox. I will provide C# code snippet. Hope it helps class Sample : INotifyPropertyChanged { private string firstName; public string FirstName { get { return firstName; } set { firstName = value; InvokePropertyChanged(new PropertyChangedEventArgs(“FirstName”)); } } #region Implementation of INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; public void InvokePropertyChanged(PropertyChangedEventArgs … Read more

WPF Radiobutton (two) (binding to boolean value)

<RadioButton GroupName=”Group1″ IsChecked=”{Binding PropertyValue}” Content=”Yes” /> <RadioButton GroupName=”Group1″ Content=”No” IsChecked=”{Binding PropertyValue, Converter={StaticResource BoolInverterConverter}}” /> public class BoolInverterConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is bool) { return !(bool)value; } return value; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) … Read more

In WPF, why doesn’t TemplateBinding work where Binding does?

Found this forum post on MSDN: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0bb3858c-30d6-4c3d-93bd-35ad0bb36bb4/ It says this: A TemplateBinding is an optimized form of a Binding for template scenarios, analogous to a Binding constructed with {Binding RelativeSource={RelativeSource TemplatedParent}} Note from OP: Contrary to what it says in the documentation, in actuality, it should be this… {Binding RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay} I filed a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)