Ok so.. I'm a bit lost. What i have is a
window1.xaml
just a combobox that selects different Enviroments
then i have a which displays data based on environment
I have a default environment when app loads up and displays the correct data.
Question: I want the Dashboards data to change when a different Environment is selected.
I've been struggling with this for a day now and I'm not getting anywhere.... Any help would be appreciated...
Code so far:
EnvironmentView.xaml
<UserControl.DataContext>
<vm:EnvironmentViewModel />
</UserControl.DataContext>
<StackPanel Orientation="Horizontal">
<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" Text="Environment:" Margin="0,0,5,0" />
<ComboBox x:Name="environments" ItemsSource="{Binding Data}" SelectedItem="{Binding Data}" SelectedIndex="0" ></ComboBox>
</StackPanel>
EnivronmentViewModel.cs
public class EnvironmentViewModel : BaseModelView {
public ObservableCollection<string> _data;
public ObservableCollection<string> Data
{
get {
if (this._data == null)
{
_data = new ObservableCollection<string>();
foreach (ConnectionStringSettings connectionString in ConfigurationManager.ConnectionStrings)
{
this._data.Add(connectionString.Name);
}
}
return this._data;
}
set {
if (_data == value) return;
_data = value;
OnPropertyChanged("Data");
}
}
DashboardView.xaml
<UserControl.DataContext>
<viewmodel:DashboardViewModel />
</UserControl.DataContext>
<Border Style="{StaticResource ThickBorderStyle}">
<StackPanel>
<TextBlock Text="Current Bugs" />
<data:DataGrid x:Name="dataview" Width="Auto" Height="Auto" ItemsSource="{Binding Data}">
</data:DataGrid>
</StackPanel>
</Border>
DashboardViewModel.cs
private DashboardRepository _repository;
public ObservableCollection<DashBoardCount> _data;
public DashboardViewModel() {
_repository = new DashboardRepository();
}
public ObservableCollection<DashBoardCount> Data
{
get
{
if(this._data==null)
{
IQuery q = new Query() { ConnectionStringKey = this.ConnectionStringKey };
_data = this._repository.Get(q);
}
return _data;
}
set {
if (_data == value) return;
_data = value;
OnPropertyChanged("Data");
}
}