ListView SelectedValue Binding issue
-
Hi all, I have a simple listview that has a currently selected item binding as follow:
<ListView HorizontalAlignment="Left" Width="300" Name="ServiceListView" SelectionChanged="ServiceListView_SelectionChanged" SelectedValue="{Binding CurrentlySelectedService}" Grid.Row="0" Grid.RowSpan="2" Grid.Column="0">
<ListView.View>
<GridView>
<GridViewColumn Header="Machine">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label x:Name="ServiceNames" Content="{Binding ServiceController.MachineName}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Service Names">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label x:Name="ServiceNames" Content="{Binding ServiceController.ServiceName}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Service status">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label Width="80" x:Name="ServiceStatus" Content="{Binding ServiceController.CurrentStatus}" Background="{Binding ServiceController.ServiceStatusColour}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>And obviously in the constructor I do the following to enable bindings:
DataContext = this;
The problem: The binding to SelectedValue="{Binding CurrentlySelectedService}" works 100% (well, sort of). In my DEV environment it works 100% and the currently selected item works 100%. But for some or other reason when I deploy this to a Windows server 2003 box (with .Net 3.5 installed), the binding doesn't work anymore... How can I debug this issue? Has anyone experienced this problem before? This is not my first time experiencing this problem. I've seen this a few times now, but it seems to be very PC specific. It will work 100% on one pc, and then completely FAILS on another. Any help would be much appreciated.
-
Hi all, I have a simple listview that has a currently selected item binding as follow:
<ListView HorizontalAlignment="Left" Width="300" Name="ServiceListView" SelectionChanged="ServiceListView_SelectionChanged" SelectedValue="{Binding CurrentlySelectedService}" Grid.Row="0" Grid.RowSpan="2" Grid.Column="0">
<ListView.View>
<GridView>
<GridViewColumn Header="Machine">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label x:Name="ServiceNames" Content="{Binding ServiceController.MachineName}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Service Names">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label x:Name="ServiceNames" Content="{Binding ServiceController.ServiceName}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Service status">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Label Width="80" x:Name="ServiceStatus" Content="{Binding ServiceController.CurrentStatus}" Background="{Binding ServiceController.ServiceStatusColour}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>And obviously in the constructor I do the following to enable bindings:
DataContext = this;
The problem: The binding to SelectedValue="{Binding CurrentlySelectedService}" works 100% (well, sort of). In my DEV environment it works 100% and the currently selected item works 100%. But for some or other reason when I deploy this to a Windows server 2003 box (with .Net 3.5 installed), the binding doesn't work anymore... How can I debug this issue? Has anyone experienced this problem before? This is not my first time experiencing this problem. I've seen this a few times now, but it seems to be very PC specific. It will work 100% on one pc, and then completely FAILS on another. Any help would be much appreciated.
-
Got snoop ... didn't think of using it. Why the DataContext ? If the DataContext is not the correct one, how does one go about setting the correct one ...?
-
Got snoop ... didn't think of using it. Why the DataContext ? If the DataContext is not the correct one, how does one go about setting the correct one ...?
The reason I suggested this, is that it sounds like the DataContext is behaving differently between the two machines. Snoop can be used to help you determine if this is the case.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.