Honza K.
Honza K.
CC#
Created by Honza K. on 3/29/2024 in #help
Avalonia UI - binding in markup extension?
Hi, I'm trying to create a localization extension for my new desktop app and I want to support binding in my localization markup extension, how can I do that? I can receive the binding (CompiledBindingExtension) as a parameter and somehow I managed to get a value out of it to translate it but only by changing the Converter instance in the binding, which can be no-go in the future and also if I changed the language, all other localized strings changed because I used a ReflectionBinding for them but I don't know how to do it when I accept binding as a parameter? I'm kinda lost... Can anyone help me please? Here is my current implementation that only accept string keys: (I deleted the implementation for the binding as it was not working properly...)
2 replies
CC#
Created by Honza K. on 7/7/2023 in #help
✅ public readonly bool Equals(...)? - SOLVED
I created struct for my needs of representing a phone number prefix and intellisense offered me a "potential fix" which after applying added readonly modifier to a method return type? Can you explain to me what this does as I see it first time in my 5 years of c#-ing?
public struct PhoneNumberPrefix : IEqualityComparer<PhoneNumberPrefix>
{
public PhoneNumberPrefix(int intValue, string stringValue)
{
IntValue = intValue;
StringValue = stringValue;
}
public int IntValue { get; set; } = 0;
public string StringValue { get; set; } = "";

public readonly bool Equals(PhoneNumberPrefix x, PhoneNumberPrefix y)
{
return x.IntValue == y.IntValue && x.StringValue == y.StringValue;
}

public int GetHashCode(PhoneNumberPrefix obj)
{
throw new NotImplementedException();
}
}
public struct PhoneNumberPrefix : IEqualityComparer<PhoneNumberPrefix>
{
public PhoneNumberPrefix(int intValue, string stringValue)
{
IntValue = intValue;
StringValue = stringValue;
}
public int IntValue { get; set; } = 0;
public string StringValue { get; set; } = "";

public readonly bool Equals(PhoneNumberPrefix x, PhoneNumberPrefix y)
{
return x.IntValue == y.IntValue && x.StringValue == y.StringValue;
}

public int GetHashCode(PhoneNumberPrefix obj)
{
throw new NotImplementedException();
}
}
And yes... It compiles 😄
8 replies
CC#
Created by Honza K. on 6/8/2023 in #help
❔ Intellisense not showing styles for custom controls
Hi, we're using ModernWpf library and we have our own styles for some of their controls, for example hyperlink button, and intellisense in xaml is not showing the styles for this control, why is that? We have our own WPF controls library with custom styles (just like ModernWpf is) that is built on top of ModernWpf, but in the actual WPF application intellisense is not suggesting styles that are for ModernWpf custom controls. Everything is correctly done in app.xaml, designer itself is working great with our styles (had to edit ModernWpf tho), but our styles for ModernWpf controls are not suggested when writign xaml... Any idea why?
3 replies