Use “real” CultureInfo.CurrentCulture in WPF Binding, not CultureInfo from IetfLanguageTag

You can create a subclass of binding (e.g. CultureAwareBinding) which sets the ConverterCulture automatically to the current culture when created. It’s not a perfect solution, but it’s probably the only one, since retroactively forcing Binding to respect the culture could break other code in WPF which depends on this behavior. Let me know if you … Read more

WPF Binding : Casting in binding path

The solution for the problem, finally, is to use following syntax: Path=Item.(myNameSpace:IEdge.Tag).caption The previous code cast Item to the type IEdge in order to access the Tag property. In case of multiple nested casts the global pattern is : Path=Obj1.(ns1:TypeObj1.Obj2).(ns2:TypeObj2.Obj3)…(nsN:TypeObjN.BindedProp) As suggested in comments Do not use shorthand binding syntax when using this solution. Ensure … Read more

WPF Trigger based on Object Type

This is based on @AndyG’s answer but is a bit safer because it’s strongly typed. Implement an IValueConverter named DataTypeConverter, which accepts an object and returns its Type (as a System.Type): public class DataTypeConverter:IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return value?.GetType() ?? Binding.DoNothing; } public object ConvertBack(object value, … Read more

Android how do I wait until a service is actually connected?

How can I wait for ServiceConnection.onServiceConnected being called reliably? You don’t. You exit out of onCreate() (or wherever you are binding) and you put you “needs the connection established” code in onServiceConnected(). Are all the event handlers: Activity.onCreate, any View.onClickListener.onClick, ServiceConnection.onServiceConnected, etc. actually called in the same thread Yes. When exactly is ServiceConnection.onServiceConnected actually going … Read more

WPF StringFormat={0:C} showing as dollars

I’m not sure if this has been fixed in .NET 4, but WPF has never picked up the current culture when rendering things like currency or dates. It’s something I consider a massive oversight, but thankfully is easily corrected. In your App class: protected override void OnStartup(StartupEventArgs e) { FrameworkElement.LanguageProperty.OverrideMetadata( typeof(FrameworkElement), new FrameworkPropertyMetadata( XmlLanguage.GetLanguage( CultureInfo.CurrentCulture.IetfLanguageTag))); … Read more

How to bind list to dataGridView?

Use a BindingList and set the DataPropertyName-Property of the column. Try the following: … private void BindGrid() { gvFilesOnServer.AutoGenerateColumns = false; //create the column programatically DataGridViewCell cell = new DataGridViewTextBoxCell(); DataGridViewTextBoxColumn colFileName = new DataGridViewTextBoxColumn() { CellTemplate = cell, Name = “Value”, HeaderText = “File Name”, DataPropertyName = “Value” // Tell the column which property … Read more

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