DapperDeer
DapperDeer
CC#
Created by DapperDeer on 12/27/2023 in #help
Dependency Properties and When to use ObservableCollections
I fgured out how to get this to work: I needed to create a PropertyChangedCallback and set the PokemonDetails collection to the new value. I would've thought this just happened with the Setter, but I guess not?
6 replies
CC#
Created by DapperDeer on 12/27/2023 in #help
Dependency Properties and When to use ObservableCollections
The ListBox in PokemonDetails.xaml is within a Grid, which is specifying <Grid DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type wpfApp1:PokemonDetails}}}">
6 replies
CC#
Created by DapperDeer on 12/27/2023 in #help
Dependency Properties and When to use ObservableCollections
PokemonDetails.xaml.cs (truncated for brevity)
public ObservableCollection<Pokemon> Pokemon
{
get => (ObservableCollection<Pokemon>)GetValue(PokemonContentsProperty);
set
{
SetValue(PokemonContentsProperty, value);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Pokemon)));
}
}

public static readonly DependencyProperty PokemonContentsProperty = DependencyProperty.Register(
name: "Pokemon",
propertyType: typeof(ObservableCollection<Pokemon>),
ownerType: typeof(PokemonDetails));
public ObservableCollection<Pokemon> Pokemon
{
get => (ObservableCollection<Pokemon>)GetValue(PokemonContentsProperty);
set
{
SetValue(PokemonContentsProperty, value);
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Pokemon)));
}
}

public static readonly DependencyProperty PokemonContentsProperty = DependencyProperty.Register(
name: "Pokemon",
propertyType: typeof(ObservableCollection<Pokemon>),
ownerType: typeof(PokemonDetails));
6 replies
CC#
Created by DapperDeer on 12/27/2023 in #help
Dependency Properties and When to use ObservableCollections
PokemonDetails.xaml (truncated for brevity):
<ListBox
x:Name="PokemonListBox"
Grid.Row="1"
HorizontalContentAlignment="Center"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{Binding Pokemon}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<Image Source="{Binding ImageSource}" Width="64" Height="64" />
<TextBlock Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox
x:Name="PokemonListBox"
Grid.Row="1"
HorizontalContentAlignment="Center"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ItemsSource="{Binding Pokemon}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<Image Source="{Binding ImageSource}" Width="64" Height="64" />
<TextBlock Text="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
6 replies
CC#
Created by DapperDeer on 12/27/2023 in #help
Dependency Properties and When to use ObservableCollections
MainWindow.xaml:
<ContentControl Grid.Column="1">
<local:PokemonDetails Pokemon="{Binding Pokemon, UpdateSourceTrigger=PropertyChanged, BindsDirectlyToSource=True}"/>
</ContentControl>
<ContentControl Grid.Column="1">
<local:PokemonDetails Pokemon="{Binding Pokemon, UpdateSourceTrigger=PropertyChanged, BindsDirectlyToSource=True}"/>
</ContentControl>
6 replies
CC#
Created by DapperDeer on 12/19/2023 in #help
EntityFramework Property Binding
Thanks, Z :)
8 replies
CC#
Created by DapperDeer on 12/19/2023 in #help
EntityFramework Property Binding
On the DbContext!
8 replies
CC#
Created by DapperDeer on 12/19/2023 in #help
EntityFramework Property Binding
Is that on the DbContext or in the OnModelCreating?
8 replies
CC#
Created by DapperDeer on 12/19/2023 in #help
EntityFramework Property Binding
I have a DbContextFactory that I am using to get a new DbContext and assigning the calling class's ObservableCollection<Pokemon> prop to DbContext.Set<Pokemon>(), so it could also be how I'm calling and getting the values, but I think it's more to do with how I'm setting up the model creation.
8 replies
CC#
Created by DapperDeer on 11/17/2022 in #help
❔ Single UDP Broadcaster to Multiple Clients
Unhandled exception. System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted.
5 replies
CC#
Created by DapperDeer on 11/17/2022 in #help
❔ Single UDP Broadcaster to Multiple Clients
The exception that's thrown when trying to spin up additional listeners is:
5 replies