Jason_Bjorn
Jason_Bjorn
CC#
Created by Jason_Bjorn on 8/23/2024 in #help
✅ Avalonia - Can't see anything even though control is styled
The main window is super simple so I am not sure how I could've messed that up
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:AvaloniaRatingsControl.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:AvaloniaRatingsControl.Controls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AvaloniaRatingsControl.Views.MainWindow"
x:CompileBindings="True"
x:DataType="vm:MainWindowViewModel"
Icon="/Assets/avalonia-logo.ico"
Title="RatingControlSample">


<Design.DataContext>
<vm:MainWindowViewModel />
</Design.DataContext>
<controls:RatingControl NumberOfStars="5" Value="4"/>
</Window>
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:AvaloniaRatingsControl.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:AvaloniaRatingsControl.Controls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AvaloniaRatingsControl.Views.MainWindow"
x:CompileBindings="True"
x:DataType="vm:MainWindowViewModel"
Icon="/Assets/avalonia-logo.ico"
Title="RatingControlSample">


<Design.DataContext>
<vm:MainWindowViewModel />
</Design.DataContext>
<controls:RatingControl NumberOfStars="5" Value="4"/>
</Window>
3 replies
CC#
Created by Jason_Bjorn on 8/23/2024 in #help
✅ Avalonia - Can't see anything even though control is styled
No description
3 replies
CC#
Created by Jason_Bjorn on 8/16/2024 in #help
Avalonia IconPath not showing up
I thought Width might be the width of the stroke, but it isn't
9 replies
CC#
Created by Jason_Bjorn on 8/16/2024 in #help
Avalonia IconPath not showing up
No description
9 replies
CC#
Created by Jason_Bjorn on 8/16/2024 in #help
Avalonia IconPath not showing up
No description
9 replies
CC#
Created by Jason_Bjorn on 8/16/2024 in #help
Avalonia IconPath not showing up
fixed it, the resource name was wrong, strange that I don't get an error for that
9 replies
CC#
Created by Jason_Bjorn on 8/16/2024 in #help
Avalonia IconPath not showing up
I am guessing the width is too small but why can't I set that in Avalonia?
9 replies
CC#
Created by Jason_Bjorn on 8/16/2024 in #help
Avalonia IconPath not showing up
<StreamGeometry x:Key="AddIconData">M356.556,857.583C388.791,857.583 388.633,860.246 656.509,849.531C762.201,845.303 897.659,849.525 1070.7,849.539C1083.69,820.659 1090.44,613.74 1073.22,493.211C1055.05,365.987 1089.33,363.491 1089.33,203.324C1089.33,125.926 1093.03,124.073 1099.39,122.799C1120.31,118.616 1120.49,121.041 1365.12,100.655C1435.94,94.754 1435.44,100.746 1505.82,94.508C1540.5,345.985 1473.13,603.133 1489.96,803.371C1782.56,774.862 1782.22,785.111 2168.35,785.111C2228.74,785.111 2231.71,799.948 2232.77,805.242C2237.13,827.05 2252.54,904.068 2222.7,1083.05C2211.08,1152.79 2234.74,1174.15 2180.43,1187.73C2125.63,1201.43 1887.93,1172.58 1546.3,1185.72C1497.13,1187.61 1489.05,1179.92 1487.92,1195.79C1471.01,1432.55 1473.99,1432.86 1465.78,1457.49C1443.42,1524.56 1465.85,1724.53 1469.86,1829.98C1212.66,1819.76 1025.04,1795.82 1018.87,1789.65C953.424,1724.21 1042.25,1247.19 1055.1,1195.79C1059.24,1179.23 1011.51,1201.49 960.488,1207.86C890.498,1216.61 891.816,1220.13 821.583,1225.98C790.735,1228.55 521.343,1251 435.067,1207.86C414.975,1197.82 310.971,1197.76 300.148,1197.76C304.904,1104.62 295.437,1068.58 318.49,862.067C336.532,853.881 336.226,855.816 356.556,853.557</StreamGeometry>
<StreamGeometry x:Key="AddIconData">M356.556,857.583C388.791,857.583 388.633,860.246 656.509,849.531C762.201,845.303 897.659,849.525 1070.7,849.539C1083.69,820.659 1090.44,613.74 1073.22,493.211C1055.05,365.987 1089.33,363.491 1089.33,203.324C1089.33,125.926 1093.03,124.073 1099.39,122.799C1120.31,118.616 1120.49,121.041 1365.12,100.655C1435.94,94.754 1435.44,100.746 1505.82,94.508C1540.5,345.985 1473.13,603.133 1489.96,803.371C1782.56,774.862 1782.22,785.111 2168.35,785.111C2228.74,785.111 2231.71,799.948 2232.77,805.242C2237.13,827.05 2252.54,904.068 2222.7,1083.05C2211.08,1152.79 2234.74,1174.15 2180.43,1187.73C2125.63,1201.43 1887.93,1172.58 1546.3,1185.72C1497.13,1187.61 1489.05,1179.92 1487.92,1195.79C1471.01,1432.55 1473.99,1432.86 1465.78,1457.49C1443.42,1524.56 1465.85,1724.53 1469.86,1829.98C1212.66,1819.76 1025.04,1795.82 1018.87,1789.65C953.424,1724.21 1042.25,1247.19 1055.1,1195.79C1059.24,1179.23 1011.51,1201.49 960.488,1207.86C890.498,1216.61 891.816,1220.13 821.583,1225.98C790.735,1228.55 521.343,1251 435.067,1207.86C414.975,1197.82 310.971,1197.76 300.148,1197.76C304.904,1104.62 295.437,1068.58 318.49,862.067C336.532,853.881 336.226,855.816 356.556,853.557</StreamGeometry>
9 replies
CC#
Created by Jason_Bjorn on 8/16/2024 in #help
Avalonia IconPath not showing up
No description
9 replies
CC#
Created by Jason_Bjorn on 8/16/2024 in #help
Avalonia IconPath not showing up
I drew it in Affinity designer and exported to SVG, opened in notepad and copied that path
9 replies
CC#
Created by Jason_Bjorn on 8/12/2024 in #help
✅ Avalonia - Textbox text changed
Found it just by guessing it is TextChanged
2 replies
CC#
Created by Jason_Bjorn on 8/9/2024 in #help
✅ A nicer way to create an on-demand property?
Thanks
14 replies
CC#
Created by Jason_Bjorn on 8/9/2024 in #help
✅ A nicer way to create an on-demand property?
// method 3 using Lazy<int> and field initilizer
private Lazy<int> tum = new Lazy<int>(() =>
{
Console.WriteLine("Calculating tum");
return X + Y;
});
public int Tum
{
get
{
return tum.Value;
}
}
// method 3 using Lazy<int> and field initilizer
private Lazy<int> tum = new Lazy<int>(() =>
{
Console.WriteLine("Calculating tum");
return X + Y;
});
public int Tum
{
get
{
return tum.Value;
}
}
14 replies
CC#
Created by Jason_Bjorn on 8/9/2024 in #help
✅ A nicer way to create an on-demand property?
field initializers cannot reference non-static properties
14 replies
CC#
Created by Jason_Bjorn on 8/9/2024 in #help
✅ A nicer way to create an on-demand property?
putting the logic of initializing bum into the constructor just seems weird
14 replies
CC#
Created by Jason_Bjorn on 8/9/2024 in #help
✅ A nicer way to create an on-demand property?
Foo f = new()
{
X = 3,
Y = 4
};

f.Dump();

class Foo
{
public required int X { get; init; }
public required int Y { get; init; }
private int? sum = null;

public int Sum
{
get
{
Console.WriteLine("Calculating Sum");
sum ??= X + Y;
return sum.Value;
}
}

private Lazy<int> bum; // no longer needs to be int? which is nice
public int Bum // getter no longer needs to worry about the logic behind the value of bum, which is nice
{
get
{
return bum.Value;
}
}

public Foo() // constructor needed to let Bum know how to get the value of bum
{
bum = new Lazy<int>(() =>
{
Console.WriteLine("Calculating Bum");
return X + Y;
});
}
}
Foo f = new()
{
X = 3,
Y = 4
};

f.Dump();

class Foo
{
public required int X { get; init; }
public required int Y { get; init; }
private int? sum = null;

public int Sum
{
get
{
Console.WriteLine("Calculating Sum");
sum ??= X + Y;
return sum.Value;
}
}

private Lazy<int> bum; // no longer needs to be int? which is nice
public int Bum // getter no longer needs to worry about the logic behind the value of bum, which is nice
{
get
{
return bum.Value;
}
}

public Foo() // constructor needed to let Bum know how to get the value of bum
{
bum = new Lazy<int>(() =>
{
Console.WriteLine("Calculating Bum");
return X + Y;
});
}
}
Is the bum approach better?
14 replies
CC#
Created by Jason_Bjorn on 8/9/2024 in #help
✅ A nicer way to create an on-demand property?
I was thinking about using Lazy but that doesn't seem to clean thing up
14 replies
CC#
Created by Jason_Bjorn on 8/9/2024 in #help
✅ Generic function with conditional type based logic inside
thanks for your help @Joschi
31 replies
CC#
Created by Jason_Bjorn on 8/9/2024 in #help
✅ Generic function with conditional type based logic inside
most time is probably spent on computing the hash
31 replies
CC#
Created by Jason_Bjorn on 8/9/2024 in #help
✅ Generic function with conditional type based logic inside
This is in a directory with ~140 image files
31 replies