Honza K.
Honza K.
CC#
Created by Neo | QuantFreedom on 11/9/2024 in #help
Avalonia Data Trigger
You can also apply classes to a control based on some condition, which can be pretty handy https://docs.avaloniaui.net/docs/basics/user-interface/styling/style-classes#conditional-classes
23 replies
CC#
Created by Neo | QuantFreedom on 11/9/2024 in #help
Avalonia Data Trigger
you can also select something by some of its property value https://docs.avaloniaui.net/docs/reference/styles/style-selector-syntax#by-property-match
23 replies
CC#
Created by Neo | QuantFreedom on 11/9/2024 in #help
Avalonia Data Trigger
you have to use template selector whenever in the default template they decided to change some properties of something that isn't shown in logical tree of the control, in case of a button, the background is set on a ContentPresenter and in case of :pointerover trigger, they're setting the background the same way you have to, they select the parent (button/toogle button), go into template selector and select ContentPresenter#PART_ContentPresenter (ContentPresenter type with PART_ContentPresenter name) and set the Background property to some value
23 replies
CC#
Created by Honza K. on 3/29/2024 in #help
Avalonia UI - binding in markup extension?
public class StringLocalizationExtension : MarkupExtension
{
#pragma warning disable IDE0290 // Use primary constructor
public StringLocalizationExtension(string key)
{
Key = key;
}
#pragma warning restore IDE0290 // Use primary constructor
public string? Key { get; set; }

public override object ProvideValue(IServiceProvider serviceProvider)
{
var binding = new ReflectionBindingExtension($"[{Key}]")
{
Mode = BindingMode.OneWay,
Source = Internal.StringLocalizationResolver.Instance,
};

return binding.ProvideValue(serviceProvider);
}
}

public class StringLocalizationResolver(ICAFluentUINet.Abstractions.Localization.IStringLocalizer stringLocalizer) : INotifyPropertyChanged
{
private readonly IStringLocalizer _stringLocalizer = stringLocalizer;
private const string IndexerName = "Item";
private const string IndexerArrayName = "Item[]";

#pragma warning disable CS8612 // Nullability of reference types in type doesn't match implicitly implemented member.
public event PropertyChangedEventHandler PropertyChanged;
#pragma warning restore CS8612 // Nullability of reference types in type doesn't match implicitly implemented member.
public static StringLocalizationResolver? Instance { get; set; }

public string this[string key] => _stringLocalizer.Get(key);

public void Invalidate()
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(IndexerName));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(IndexerArrayName));
}
}
public class StringLocalizationExtension : MarkupExtension
{
#pragma warning disable IDE0290 // Use primary constructor
public StringLocalizationExtension(string key)
{
Key = key;
}
#pragma warning restore IDE0290 // Use primary constructor
public string? Key { get; set; }

public override object ProvideValue(IServiceProvider serviceProvider)
{
var binding = new ReflectionBindingExtension($"[{Key}]")
{
Mode = BindingMode.OneWay,
Source = Internal.StringLocalizationResolver.Instance,
};

return binding.ProvideValue(serviceProvider);
}
}

public class StringLocalizationResolver(ICAFluentUINet.Abstractions.Localization.IStringLocalizer stringLocalizer) : INotifyPropertyChanged
{
private readonly IStringLocalizer _stringLocalizer = stringLocalizer;
private const string IndexerName = "Item";
private const string IndexerArrayName = "Item[]";

#pragma warning disable CS8612 // Nullability of reference types in type doesn't match implicitly implemented member.
public event PropertyChangedEventHandler PropertyChanged;
#pragma warning restore CS8612 // Nullability of reference types in type doesn't match implicitly implemented member.
public static StringLocalizationResolver? Instance { get; set; }

public string this[string key] => _stringLocalizer.Get(key);

public void Invalidate()
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(IndexerName));
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(IndexerArrayName));
}
}
2 replies
CC#
Created by Kagano on 2/26/2024 in #help
✅ Avalonia UI button doesn't color by hover!
you must change it in the template itself...
<Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource Button.MouseOver.Background}"/>
<Setter Property="TextBlock.Foreground" Value="{DynamicResource Button.Foreground}"/>
</Style>
<Style Selector="Button:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource Button.MouseOver.Background}"/>
<Setter Property="TextBlock.Foreground" Value="{DynamicResource Button.Foreground}"/>
</Style>
4 replies
CC#
Created by 𝕭𝖔𝖙𝖙𝖑𝖊_𝕭𝖆𝖗𝖔𝖓 on 2/23/2024 in #help
Trying to scaffold a controller for ASP .NET api using MongoDB but get this message
This shit gets broken quite often actually... I never managed to fix it, I always created a new empty project and did the scaffold action there and just copied the stuff out to my actual project 😄
5 replies
CC#
Created by Shiv on 2/19/2024 in #help
Scheduling task in c# with failproof mechanism
thanks for the info, my answer is based purely on the Nick's video and I didn't look at the library myself... It's good to know it is a paid library and the free version kinda sucks
14 replies
CC#
Created by Shiv on 2/19/2024 in #help
Scheduling task in c# with failproof mechanism
14 replies
CC#
Created by lugende on 1/11/2024 in #help
why does this Not work?
3 replies
CC#
Created by stuw on 1/8/2024 in #help
Parallel.For but that doesn't allocate.
what are you comparing it against? if you want to benchmark something, try using this https://github.com/dotnet/BenchmarkDotNet
4 replies
CC#
Created by Mayka on 1/8/2024 in #help
WPF Data Binding Shows Blank
Also you might want to consider creating a viewmodel instead of setting datacontext to the view itself
9 replies
CC#
Created by Mayka on 1/8/2024 in #help
WPF Data Binding Shows Blank
All properties that are used for binding must be public
9 replies
CC#
Created by Justdie on 1/5/2024 in #help
import every function from a C module
No, it's still one to one relationship... One DllImport per function, is it annoying? If you have many functions, yes 😄
6 replies
CC#
Created by ~✰ 𝒮𝓉𝑒𝓁𝓁𝒶𝓇 ✰~ on 1/3/2024 in #help
Null Reference error but it's not null?
can you send the call stack from the exception?
49 replies
CC#
Created by ~✰ 𝒮𝓉𝑒𝓁𝓁𝒶𝓇 ✰~ on 1/3/2024 in #help
Null Reference error but it's not null?
show us the call stack pls
49 replies
CC#
Created by mauriziopatino on 1/2/2024 in #help
WPF Visibility binding seems that is not setting style
oh, my bad for not reading your question/problem properly 😄 sry
11 replies
CC#
Created by mauriziopatino on 1/2/2024 in #help
WPF Visibility binding seems that is not setting style
or you can use binding converter
11 replies
CC#
Created by mauriziopatino on 1/2/2024 in #help
WPF Visibility binding seems that is not setting style
I dont think the property can be of type string, it should be of a correct type, which is Visibility in this case
11 replies
CC#
Created by UltraWelfare on 12/26/2023 in #help
Organizing and naming different closely related Dtos
what I want to say is, consider building the API for the needs of the UI, it can save you a lot of work and it could actually also save you some troubleshooting
47 replies