Elio
Elio
CC#
Created by Elio on 11/6/2024 in #help
Visual error
No description
2 replies
CC#
Created by Elio on 10/28/2024 in #help
Garbage Management wpf
Hi, I'd like to know how to manage process memory in my software. Here is some code that has a constructor with a modalNavigationStore parameter, which is a singleton that I never dispose of. I'd like to know if I need to set _modalNavigationStore = null to ensure proper disposal and garbage collection when i'm done with my service ?
public class Service
{
#region Fields
protected TaskCompletionSource<DialogResult>? _dialogtcs;
protected ModalNavigationStore _modalNavigationStore;

#region Constructors
public Service(ModalNavigationStore modalNavigationStore)
{
_modalNavigationStore = modalNavigationStore;
_parameterNavigationService = navigationService;
}
#endregion
}
public class Service
{
#region Fields
protected TaskCompletionSource<DialogResult>? _dialogtcs;
protected ModalNavigationStore _modalNavigationStore;

#region Constructors
public Service(ModalNavigationStore modalNavigationStore)
{
_modalNavigationStore = modalNavigationStore;
_parameterNavigationService = navigationService;
}
#endregion
}
24 replies
CC#
Created by Elio on 10/8/2024 in #help
Project Installer
Hi, i've created a .Net 8.0 Wpf application and i'd like to know which project installer i should choose between wix Toolsets and Microsoft Visual Studio Installer Projects 2022 ? It seems likes Visual Studio Installer Projects 2022 are more .net Framework app oriented.
27 replies
CC#
Created by Elio on 9/26/2024 in #help
Dynamic Culture WPF
No description
3 replies
CC#
Created by Elio on 8/7/2024 in #help
Validation Error Template
No description
1 replies
CC#
Created by Elio on 7/15/2024 in #help
Clip content in a Border
No description
1 replies
CC#
Created by Elio on 6/17/2024 in #help
Access dependency property from a viewmodel WPF
HI, i'm using WPF and MVVM pattern. i've created a DependencyProperty IsEditable and how do i access this one from my viewmodel to bind it to CanExecute for my command.
public class ListingUserControl : UserControl
{
#region Properties
public bool IsEditable
{
get => (bool)GetValue(IsEditableProperty);
set => SetValue(IsEditableProperty, value);
}

public static readonly DependencyProperty IsEditableProperty =
DependencyProperty.Register(
"IsEditable",
typeof(bool),
typeof(ListingUserControl),
new PropertyMetadata(true));
#endregion

}
public class ListingUserControl : UserControl
{
#region Properties
public bool IsEditable
{
get => (bool)GetValue(IsEditableProperty);
set => SetValue(IsEditableProperty, value);
}

public static readonly DependencyProperty IsEditableProperty =
DependencyProperty.Register(
"IsEditable",
typeof(bool),
typeof(ListingUserControl),
new PropertyMetadata(true));
#endregion

}
private bool CanExecuteCommand() { return IsEditable; }
private bool CanExecuteCommand() { return IsEditable; }
4 replies
CC#
Created by Elio on 5/16/2024 in #help
WPF Datagrid Extended
No description
1 replies
CC#
Created by Elio on 5/2/2024 in #help
Visualizer XAML
Hi, i've created my own ToggleButton Control and i was wondering how to remove the Cannot find resource named <Resource name>. error in the xaml vizualizer ? Because it can display my control on runtime and even in xaml vizualizer but it bother me to see this ghost error. here the code if it can help : https://paste.mod.gg/zaxjipozqilv/4
2 replies
CC#
Created by Elio on 4/26/2024 in #help
✅ JSON Deserialize Derived Class
Hi, i'm struggling to deserialize my object with the Newtonsoft.Json Librairy. I've a collection of Step named Steps which can be a Stepspecial or Stepnormal. I'm trying to write my JsonConverter to deserialize the collection of Step but when i try to deserialize i keep getting the stack overflow error because jObject.ToObject call back ReadJson :
public class StepConverterJSON : JsonConverter<Step>
{
#region Properties
public override bool CanWrite => false;
#endregion

#region Override Methods
public override void WriteJson(JsonWriter writer, Step? value, JsonSerializer serializer) { throw new NotImplementedException(); }

public override Step? ReadJson(JsonReader reader, Type objectType, Step? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
// Load a JObject from the JsonReader
JObject jObject = JObject.Load(reader);

if(jObject["Message"] != null)
{
// Use the new serializer to deserialize the object
StepSpecial? stepSpecial = serializer.Deserialize<StepSpecial>(reader);
return stepSpecial;
}
else
{
StepNormal? stepNormal = jObject.ToObject<StepNormal>(serializer);
//StepNormal? stepNormal = serializer.Deserialize<StepNormal>(reader);
return stepNormal;
}
}
#endregion
}
public class StepConverterJSON : JsonConverter<Step>
{
#region Properties
public override bool CanWrite => false;
#endregion

#region Override Methods
public override void WriteJson(JsonWriter writer, Step? value, JsonSerializer serializer) { throw new NotImplementedException(); }

public override Step? ReadJson(JsonReader reader, Type objectType, Step? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
// Load a JObject from the JsonReader
JObject jObject = JObject.Load(reader);

if(jObject["Message"] != null)
{
// Use the new serializer to deserialize the object
StepSpecial? stepSpecial = serializer.Deserialize<StepSpecial>(reader);
return stepSpecial;
}
else
{
StepNormal? stepNormal = jObject.ToObject<StepNormal>(serializer);
//StepNormal? stepNormal = serializer.Deserialize<StepNormal>(reader);
return stepNormal;
}
}
#endregion
}
Any idea how to solve this and write a good ReadJson method ? i've thought about the populate method but not sure this is the good way of doing it.
61 replies
CC#
Created by Elio on 4/17/2024 in #help
Dependency property converter
Hi, i'm using WPF and i wanted to know if there is a way to use dependency property in a converter ? in order to write this kind of line :
<Grid>
<Grid.Resources>
<converter:UnitConverter x:Key="UnitConverter" ObservableUnit="{Binding ObsUnit}"/>
</Grid.Resources>
</Grid>
<Grid>
<Grid.Resources>
<converter:UnitConverter x:Key="UnitConverter" ObservableUnit="{Binding ObsUnit}"/>
</Grid.Resources>
</Grid>
currently i've tried this :
public class UnitConverter : DependencyObject, IValueConverter
{
#region Properties
public ObservableUnit ObservableUnit
{
get => (ObservableUnit)GetValue(ObservableUnitProperty);
set => SetValue(ObservableUnitProperty, value);
}
#endregion

#region Fields
public static readonly DependencyProperty ObservableUnitProperty =
DependencyProperty.Register("ObservableUnit", typeof(ObservableUnit), typeof(UnitConverter));
#endregion
}
public class UnitConverter : DependencyObject, IValueConverter
{
#region Properties
public ObservableUnit ObservableUnit
{
get => (ObservableUnit)GetValue(ObservableUnitProperty);
set => SetValue(ObservableUnitProperty, value);
}
#endregion

#region Fields
public static readonly DependencyProperty ObservableUnitProperty =
DependencyProperty.Register("ObservableUnit", typeof(ObservableUnit), typeof(UnitConverter));
#endregion
}
but it doesn't set my property.
1 replies
CC#
Created by Elio on 4/16/2024 in #help
Binding error Datagrid WPF
No description
1 replies
CC#
Created by Elio on 4/12/2024 in #help
✅ "Animate" an image along a axis
No description
4 replies
CC#
Created by Elio on 4/4/2024 in #help
SQLITE EFcore saving value
Hi, i'm working on a project which have a SQLITE database. I'm using EFcore to managed it. I want to know if there is a way to automatically add/remove/update by tracking or idk all the variable in my list Widths. Basically i want to call a methods Save that will add thickness if not added or add/remove/update elements in width a if thickness i already in the database.
public class Thickness
{
#region Properties
[Key]
public long Id { get; set; }

[Required]
public long MaterialId { get; set; }

[Required]
public double Value { get; set; }

public List<Width> Widths { get; set; } = new List<Width>();
}
public class Thickness
{
#region Properties
[Key]
public long Id { get; set; }

[Required]
public long MaterialId { get; set; }

[Required]
public double Value { get; set; }

public List<Width> Widths { get; set; } = new List<Width>();
}
[Table("Width")]
public class Width
{
#region Properties
[Key]
public long Id { get; set; }

[Required]
public long ThicknessId { get; set; }

[Required]
public double Value { get; set; }
}
[Table("Width")]
public class Width
{
#region Properties
[Key]
public long Id { get; set; }

[Required]
public long ThicknessId { get; set; }

[Required]
public double Value { get; set; }
}
57 replies
CC#
Created by Elio on 3/19/2024 in #help
Shitfting Image WPF
No description
1 replies
CC#
Created by Elio on 3/15/2024 in #help
Custom ToggleButon WPF
https://paste.mod.gg/siztgxijeavn/1 Hello, i'm trying to make my own togglebutton because i want it to have the property IscheckedLeft that allow me to easily switch the side of the checked value of my button. I've almost done it but i can't find a way to change my storyboard depends of IscheckedLeft. Basically i would like to Set this if IscheckedLeft = false
<ThicknessAnimation
Storyboard.TargetName="Thumb"
Storyboard.TargetProperty="Margin"
To="0 0 39 0"
Duration="0:0:0.2" />
<ThicknessAnimation
Storyboard.TargetName="Thumb"
Storyboard.TargetProperty="Margin"
To="0 0 39 0"
Duration="0:0:0.2" />
and Set this if IscheckedLeft = true
<ThicknessAnimation
Storyboard.TargetName="Thumb"
Storyboard.TargetProperty="Margin"
To="39 0 0 0"
Duration="0:0:0.2" />
<ThicknessAnimation
Storyboard.TargetName="Thumb"
Storyboard.TargetProperty="Margin"
To="39 0 0 0"
Duration="0:0:0.2" />
My problem there is if i use a converter the following error is triggered "Cannot freeze this Storyboard timeline tree for use across threads". Have you any idea how i could do this ?
1 replies
CC#
Created by Elio on 3/11/2024 in #help
✅ Deploying WPF APP
Hi, i'm a bit lost with all the informations i've found like .net Framework, .net Runtime, Publish ClickOnce etc. I'd like to have some help to deploy my wpf app. To summ up i've developped an wpf app which : - Use .Net 8 Framework - Target Windows 10 .0.17763 This app is destinated to be set on a computer which isn't connected to Internet by using a usb key. So basically i thought about an installer which include the framework if needed to download and have all the stuff related to my app to set everything on the offline computer. How i'm am supposed to do ? Do i need to create an installer by myself or the publish tool on visual studio is supposed to work if well configured ?
49 replies
CC#
Created by Elio on 1/31/2024 in #help
MVVM TOOLKIT SetProtperty
Hello, i'm trying to had a decimal number in my textbox but i can't add a . or , to write my decimal number. here is the declaration of my property that i bind to my textbox.
private readonly SymmetricRoll _symmetricRoll;
public double RollPosition
{
get => _symmetricRoll.RollPosition;
set => SetProperty(_symmetricRoll.RollPosition, value, _symmetricRoll, (symmRoll, newValue) => symmRoll.RollPosition = newValue);
}
private readonly SymmetricRoll _symmetricRoll;
public double RollPosition
{
get => _symmetricRoll.RollPosition;
set => SetProperty(_symmetricRoll.RollPosition, value, _symmetricRoll, (symmRoll, newValue) => symmRoll.RollPosition = newValue);
}
Do i need to link my textbox to a string and then i parse this string to affect the value to RollPosition ?
7 replies
CC#
Created by Elio on 1/30/2024 in #help
✅ RelayCommand CanExecute MVVM
Hi, I'm using this nuget CommunityToolkit.Mvvm.Input to add my relaycommand. i've set CanExecute this way => AddThickCommand = new RelayCommand(AddThickCommand_Execute, () => CanAddThickness); My problem there is that canexecute is trigger only when i declare AddThickCommand and canexecute is never raised again even if the boolean CanAddThickness change. I'd like to update canexecute each time CanAddThickness change to enable or not the button. Any idea why this don't work with this package ?
10 replies
CC#
Created by Elio on 1/16/2024 in #help
✅ WPF IEnumerable PropertyChanged()
Hi, Any idea why my IEnumerable variable isn't refreshed even when the Onpropertychanged is triggered ? Here is the code : https://paste.mod.gg/xucezzpuabkj/3 note that the viewmodel is correctly bind to the view.
4 replies