<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>
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)); } }}