Rodonies
Rodonies
CC#
Created by Rodonies on 9/26/2024 in #help
WPF CollectionView Filter on Property of Model?
so this is just mirroring the model but in the viewmodel space? I have never seen that before
22 replies
CC#
Created by Rodonies on 9/26/2024 in #help
WPF CollectionView Filter on Property of Model?
yeah you're right on that actually, but it just gets read in at the start and it will never change
22 replies
CC#
Created by Rodonies on 9/26/2024 in #help
WPF CollectionView Filter on Property of Model?
but that's the model right? I don't think it should notify anything even if it did
22 replies
CC#
Created by Rodonies on 9/26/2024 in #help
WPF CollectionView Filter on Property of Model?
no
22 replies
CC#
Created by Rodonies on 9/26/2024 in #help
WPF CollectionView Filter on Property of Model?
I could but it would be unused so I left it out of the code mockup
22 replies
CC#
Created by Rodonies on 9/26/2024 in #help
WPF CollectionView Filter on Property of Model?
you mean ObservableListOfY? yeah I haven't implemented propertychange on there because that collection never changes
22 replies
CC#
Created by Rodonies on 9/26/2024 in #help
WPF CollectionView Filter on Property of Model?
I'm trying hard to find a proper solution, because this problem is actually nested one level more, as in: X has a list of Z, and I want to filter based on the name of Z and it should not show any Y's NOR X's that don't have a single X that don't have a single Z
22 replies
CC#
Created by Rodonies on 9/26/2024 in #help
WPF CollectionView Filter on Property of Model?
sorry for tagging you here but you seem to be at least somewhat engaged with my question haha :p, I posted a more complete code mockup above
22 replies
CC#
Created by Rodonies on 9/26/2024 in #help
WPF CollectionView Filter on Property of Model?
you told me it shouldn't happen in the SelectedY setter but I wouldn't know where else to put it, besides in some SelectionChanged event from the listbox
22 replies
CC#
Created by Rodonies on 9/26/2024 in #help
WPF CollectionView Filter on Property of Model?
@Klarth so you are telling me to introduce a new observable list for the ListOfX from whatever Y that is selected in the viewmodel right? My question still remains as to where I should set that observablelist
22 replies
CC#
Created by Rodonies on 9/16/2024 in #help
WPF Framework Canvas Automatic Scaling based on largest coordinate in list
7 replies
CC#
Created by Rodonies on 9/16/2024 in #help
WPF Framework Canvas Automatic Scaling based on largest coordinate in list
I fully managed to get it working using this code
public class ObjectComparisonConverter : IMultiValueConverter
{
public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value[0].Equals(value[1]);
}

public object[] ConvertBack(object value, Type[] targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class ObjectComparisonConverter : IMultiValueConverter
{
public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value[0].Equals(value[1]);
}

public object[] ConvertBack(object value, Type[] targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class CoordinateConverterSingle : IMultiValueConverter
{
public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double CanvasSize = (double)value[0];
if (value.Length == 1) return CanvasSize / 2;
double LargestCoordinate = (double)value[1];
double CoordinateX = (double)value[2];

//Scalefactor
double ScaleFactor = (0.45 * CanvasSize);

//Scale
double result = CoordinateX / (LargestCoordinate / ScaleFactor);

//Translate
result += 0.5 * CanvasSize;

return result;
}

public object[] ConvertBack(object value, Type[] targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class CoordinateConverterSingle : IMultiValueConverter
{
public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double CanvasSize = (double)value[0];
if (value.Length == 1) return CanvasSize / 2;
double LargestCoordinate = (double)value[1];
double CoordinateX = (double)value[2];

//Scalefactor
double ScaleFactor = (0.45 * CanvasSize);

//Scale
double result = CoordinateX / (LargestCoordinate / ScaleFactor);

//Translate
result += 0.5 * CanvasSize;

return result;
}

public object[] ConvertBack(object value, Type[] targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
7 replies
CC#
Created by Rodonies on 9/16/2024 in #help
WPF Framework Canvas Automatic Scaling based on largest coordinate in list
https://i.imgur.com/7Lr98Na.png it used to be able to find the old Ellipse element and get me the width and height, but it can't with EllipseGeometry?
7 replies
CC#
Created by Rodonies on 9/16/2024 in #help
WPF Framework Canvas Automatic Scaling based on largest coordinate in list
Almost solved the issue myself, just need to figure out this next problem
<Path Name="Center" Fill="Blue" Stroke="Black" StrokeThickness="2">
<Path.Data>
<EllipseGeometry RadiusX="8" RadiusY="8">
<EllipseGeometry.Center>
<MultiBinding Converter="{StaticResource CConverter}">
<Binding Path="Width" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=Canvas}" Mode="OneWay" />
<Binding Path="Height" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=Canvas}" Mode="OneWay" />
<Binding Path="RadiusX" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=EllipseGeometry}" Mode="OneWay" />
<Binding Path="RadiusY" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=EllipseGeometry}" Mode="OneWay" />
</MultiBinding>
</EllipseGeometry.Center>
</EllipseGeometry>
</Path.Data>
</Path>
<Path Name="Center" Fill="Blue" Stroke="Black" StrokeThickness="2">
<Path.Data>
<EllipseGeometry RadiusX="8" RadiusY="8">
<EllipseGeometry.Center>
<MultiBinding Converter="{StaticResource CConverter}">
<Binding Path="Width" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=Canvas}" Mode="OneWay" />
<Binding Path="Height" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=Canvas}" Mode="OneWay" />
<Binding Path="RadiusX" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=EllipseGeometry}" Mode="OneWay" />
<Binding Path="RadiusY" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=EllipseGeometry}" Mode="OneWay" />
</MultiBinding>
</EllipseGeometry.Center>
</EllipseGeometry>
</Path.Data>
</Path>
I don't know why this following code can't get find the property RadiusX on the EllipseGeometry https://i.imgur.com/izux1tM.png
<Binding Path="RadiusX" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=EllipseGeometry}" Mode="OneWay" />
<Binding Path="RadiusX" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=EllipseGeometry}" Mode="OneWay" />
7 replies
CC#
Created by Rodonies on 9/16/2024 in #help
WPF Framework Canvas Automatic Scaling based on largest coordinate in list
If there is a better way without Canvas or using a different method, feel free to chime in. I have also tried ViewBox but haven't gotten that one to work as well as the solution I posted above.
<Viewbox Width="494" Height="494" RenderTransform="1 0 0 -1 0 0">
<ItemsControl ItemsSource="{Binding ListOfX}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Ellipse Width="8" Height="8" Fill="Red" Stroke="Black" StrokeThickness="2">
<Ellipse.RenderTransform>
<TranslateTransform X="{c:Binding --Calculation Here--}" Y="{c:Binding --Calculation Here--}" />
</Ellipse.RenderTransform>
</Ellipse>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Viewbox>
<Viewbox Width="494" Height="494" RenderTransform="1 0 0 -1 0 0">
<ItemsControl ItemsSource="{Binding ListOfX}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Ellipse Width="8" Height="8" Fill="Red" Stroke="Black" StrokeThickness="2">
<Ellipse.RenderTransform>
<TranslateTransform X="{c:Binding --Calculation Here--}" Y="{c:Binding --Calculation Here--}" />
</Ellipse.RenderTransform>
</Ellipse>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Viewbox>
7 replies
CC#
Created by Rodonies on 9/16/2024 in #help
WPF Framework Canvas Automatic Scaling based on largest coordinate in list
relevant code:
class Y {
public List<X> ListOfX;
public double LargestCoordinate { get { return XList.Max(o => o.Distance); } }
}

class X {
public Point Location { get; set; }
public double LargestCoordinate { get { return Math.Max(Math.Abs(Location.X), Math.Abs(Location.Y)); } }
}
class Y {
public List<X> ListOfX;
public double LargestCoordinate { get { return XList.Max(o => o.Distance); } }
}

class X {
public Point Location { get; set; }
public double LargestCoordinate { get { return Math.Max(Math.Abs(Location.X), Math.Abs(Location.Y)); } }
}
<ListBox x:Name="YListBox" Width="200" Height="333" ItemsSource="{Binding ListOfY}" SelectedItem="{Binding YListBoxSelectedItem}" />

<Border Width="494" Height="494" BorderThickness="2" BorderBrush="DarkGreen" DataContext="{Binding YListBoxSelectedItem}" Background="White">
<Canvas HorizontalAlignment="Center" VerticalAlignment="Center" Width="0" Height="0" RenderTransform="1 0 0 -1 0 0">
<Ellipse Name="Center" Width="10" Height="10" Fill="AliceBlue" Stroke="Black" StrokeThickness="2" />
<ItemsControl ItemsSource="{Binding ListOfX}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Ellipse Width="8" Height="8" Fill="AliceBlue" Stroke="Black" StrokeThickness="2">
<Ellipse.RenderTransform>
<TranslateTransform X="{c:Binding --Calculation Here--}" Y="{c:Binding --Calculation Here--}" />
</Ellipse.RenderTransform>
</Ellipse>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Canvas>
</Border>
<ListBox x:Name="YListBox" Width="200" Height="333" ItemsSource="{Binding ListOfY}" SelectedItem="{Binding YListBoxSelectedItem}" />

<Border Width="494" Height="494" BorderThickness="2" BorderBrush="DarkGreen" DataContext="{Binding YListBoxSelectedItem}" Background="White">
<Canvas HorizontalAlignment="Center" VerticalAlignment="Center" Width="0" Height="0" RenderTransform="1 0 0 -1 0 0">
<Ellipse Name="Center" Width="10" Height="10" Fill="AliceBlue" Stroke="Black" StrokeThickness="2" />
<ItemsControl ItemsSource="{Binding ListOfX}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Ellipse Width="8" Height="8" Fill="AliceBlue" Stroke="Black" StrokeThickness="2">
<Ellipse.RenderTransform>
<TranslateTransform X="{c:Binding --Calculation Here--}" Y="{c:Binding --Calculation Here--}" />
</Ellipse.RenderTransform>
</Ellipse>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Canvas>
</Border>
7 replies