IMHO, your user controls shouldn't depend directly on DataAccessUtil. Instead, expose relevant properties as DependencyProperty, and inject services, which can access DataAccessUtil, into view models.
The sample code below uses the CommunityToolkit.Mvvm NuGet package for MVVM but should help clarify what I mean.
AwesomeUserControl
<UserControl
x:Class="WinUIDemoApp.AwesomeUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:WinUIDemoApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid>
<ComboBox x:Name="AwesomeComboBox" ItemsSource="{x:Bind ComboBoxOptions, Mode=OneWay}" />
</Grid>
</UserControl>
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
namespace WinUIDemoApp;
public sealed partial class AwesomeUserControl : UserControl
{
public static readonly DependencyProperty ComboBoxOptionsProperty =
DependencyProperty.Register(
nameof(ComboBoxOptions),
typeof(object),
typeof(AwesomeUserControl),
new PropertyMetadata(default));
public AwesomeUserControl()
{
InitializeComponent();
}
public object ComboBoxOptions
{
get => (object)GetValue(ComboBoxOptionsProperty);
set => SetValue(ComboBoxOptionsProperty, value);
}
}
ComboBoxOptionsService
public interface IComboBoxOptionsService
{
string[] GetComboBoxOptions();
}
public class ComboBoxOptionsService : IComboBoxOptionsService
{
public string[] GetComboBoxOptions()
{
// Replace this demo code with options from DataAccessUtil.
int item1 = Random.Shared.Next(0, 10);
return
[
$"Option {item1}",
$"Option {item1 + 1}",
$"Option {item1 + 2}",
];
}
}
AwesomeViewModel
public partial class ShellViewModel : ObservableObject
{
private readonly IComboBoxOptionsService _comboBoxOptionsService;
public ShellViewModel(IComboBoxOptionsService comboBoxOptionsService)
{
this._comboBoxOptionsService = comboBoxOptionsService;
ComboBoxOptions = _comboBoxOptionsService.GetComboBoxOptions();
}
[ObservableProperty]
public partial string[] ComboBoxOptions { get; set; }
}
AwesomePage
<local:AwesomeUserControl ComboBoxOptions="{x:Bind ViewModel.ComboBoxOptions, Mode=OneWay}" />
public sealed partial class Shell : Page
{
public Shell()
{
InitializeComponent();
}
public AwesomeViewModel ViewModel { get; } = App.GetService<AwesomeViewModel>();
}