Feuerhamster
Feuerhamster
CC#
Created by Feuerhamster on 2/2/2023 in #help
❔ Load async data and display it (WindowsAppSDK / WinUI3)
<ScrollViewer x:Name="ScrollView" Padding="16">
<ItemsControl ItemsSource="{x:Bind Devices}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel HorizontalAlignment="Left" Orientation="Vertical" Spacing="16" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

<ItemsControl.ItemTemplate>
<DataTemplate>
<controls:AudioControl
Name="{Binding Name}"
Icon="{Binding Icon}"
Id="{Binding Id}"
Volume="{Binding Volume}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
<ScrollViewer x:Name="ScrollView" Padding="16">
<ItemsControl ItemsSource="{x:Bind Devices}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel HorizontalAlignment="Left" Orientation="Vertical" Spacing="16" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>

<ItemsControl.ItemTemplate>
<DataTemplate>
<controls:AudioControl
Name="{Binding Name}"
Icon="{Binding Icon}"
Id="{Binding Id}"
Volume="{Binding Volume}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
12 replies
CC#
Created by Feuerhamster on 2/2/2023 in #help
❔ Load async data and display it (WindowsAppSDK / WinUI3)
My app is crashing if I try to use this in xaml
12 replies
CC#
Created by Feuerhamster on 2/2/2023 in #help
❔ Load async data and display it (WindowsAppSDK / WinUI3)
And another thing...
12 replies
CC#
Created by Feuerhamster on 2/2/2023 in #help
❔ Load async data and display it (WindowsAppSDK / WinUI3)
Here is my code
public sealed partial class PlaybackDevices : Page
{
public ObservableCollection<AudioControlModel> Devices = new ObservableCollection<AudioControlModel>();

public PlaybackDevices()
{
this.InitializeComponent();
this.LoadDevices();
}

private async void LoadDevices()
{
IEnumerable<CoreAudioDevice> devices = await App.CoreAudioController.GetPlaybackDevicesAsync();

devices = devices.Where(device => device.State != DeviceState.Active).ToList();

foreach (CoreAudioDevice device in devices)
{
Devices.Add(new AudioControlModel(device.InterfaceName, device.Id, DeviceIcon.Digital, device.Volume));
}
}
}
public sealed partial class PlaybackDevices : Page
{
public ObservableCollection<AudioControlModel> Devices = new ObservableCollection<AudioControlModel>();

public PlaybackDevices()
{
this.InitializeComponent();
this.LoadDevices();
}

private async void LoadDevices()
{
IEnumerable<CoreAudioDevice> devices = await App.CoreAudioController.GetPlaybackDevicesAsync();

devices = devices.Where(device => device.State != DeviceState.Active).ToList();

foreach (CoreAudioDevice device in devices)
{
Devices.Add(new AudioControlModel(device.InterfaceName, device.Id, DeviceIcon.Digital, device.Volume));
}
}
}
12 replies
CC#
Created by Feuerhamster on 2/2/2023 in #help
❔ Load async data and display it (WindowsAppSDK / WinUI3)
Doesn't work. The UI is not responding for a moment...
12 replies