DataMemberBinding="{Binding Path=AAA.BBB.CCC}" |
I want to do the following which I can do with most of the itemcollections in the ms toolbox.
I want to be able to bind a custom property on an object to the SelectedProperty of a row in a gridview. The result would be that you could select multiple rows in a gridview and then each of the objects in the list that the Grid was bound to would have their IsSelectedProperty set to true.
Example of TreeView:
So each TreeViewItem IsSelected property is bound to the bound objects IsSelectedProperty.
<
Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
....
....
</Style>
Is this possible with the GridView?
Thanks,
<UserControl.Resources> |
<cur:AssumedLevelToColour x:Key="convAssumedLevel"/> |
<Style x:Key="assumedLevelStyle" TargetType="{x:Type telerik:GridViewCell}"> |
<Setter Property="Background"> |
<Setter.Value> |
<SolidColorBrush Color="{Binding Path=AssumedLevel, Converter={StaticResource convAssumedLevel}}" /> |
</Setter.Value> |
</Setter> |
</Style> |
</UserControl.Resources> |
<telerik:RadGridView Margin="6,6,6,6" MaxHeight="1000" Name="lstDefenders" Grid.ColumnSpan="3" SelectionChanged="lstDefenders_SelectionChanged" telerik:StyleManager.Theme="Vista" IsReadOnly="True" RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False" ColumnsWidthMode="Auto" MultipleSelect="True" > |
<telerik:RadGridView.Columns> |
<telerik:GridViewDataColumn HeaderText="Manufacturer" DataMemberBinding="{Binding Manufacturer, Mode=OneWay}" /> |
<telerik:GridViewDataColumn HeaderText="Product" DataMemberBinding="{Binding Name, Mode=OneWay}" /> |
<telerik:GridViewDataColumn CellStyle="{StaticResource assumedLevelStyle}" HeaderText="Assumed Level" DataMemberBinding="{Binding AssumedLevel, Mode=OneWay}" /> |
<telerik:GridViewDataColumn HeaderText="Type" DataMemberBinding="{Binding Type, Mode=OneWay}" /> |
<telerik:GridViewDataColumn HeaderText="Approval" DataMemberBinding="{Binding Approval, Mode=OneWay}" /> |
<telerik:GridViewDataColumn HeaderText="Notes" DataMemberBinding="{Binding Notes, Mode=OneWay}" /> |
</telerik:RadGridView.Columns> |
</telerik:RadGridView> |
Hello,
I am developing a WPF application that uses Microsoft.SqlServerCe.Client.3.5. and LINQ
I use a grid view to show data and its XAML code looks like the following
<telerik:RadGridView x:Name="unsavedFormsGridView"
Height="300"
AutoGenerateColumns="False"
ShowGroupPanel="False"
MultipleSelect="False"
ColumnsWidthMode="Fill">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Targa"
HeaderTextAlignment="Center"
Width="70"
IsReadOnly="True"
IsFilterable="False"
IsSortable="False"
DataMemberBinding="{Binding LandfillVehiclePlate}"/>
<telerik:GridViewDataColumn Header="N° formulario"
HeaderTextAlignment="Center"
Width="110"
IsReadOnly="True"
IsFilterable="False"
IsSortable="False"
DataMemberBinding="{Binding PrintedFormCode}"/>
<telerik:GridViewDataColumn x:Name="columnSave"
IsFilterable="False"
IsSortable="False">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<Button x:Name="buttonSave" Click="buttonSave_Click">
<Image Source="/Images/CheckMark.png" Height="20" Width="20" />
<Button.ToolTip>
<StackPanel Orientation="Horizontal">
<Image Source="/Images/CheckMark.png" Height="20" Width="20" />
<Label Content="Salva in modo definitivo il formulario"/>
</StackPanel>
</Button.ToolTip>
</Button>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn x:Name="columnDelete" IsFilterable="False" IsSortable="False" >
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<Button x:Name="buttonCancel" Click="buttonCancel_Click">
<Image Source="/Images/Cancel.png" Height="20" Width="20" />
<Button.ToolTip>
<StackPanel Orientation="Horizontal">
<Image Source="/Images/Cancel.png" Height="20" Width="20" />
<Label Content="Elimina in modo definitivo il formulario"/>
</StackPanel>
</Button.ToolTip>
</Button>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
To bind data to the GridView I use an observable collection of a LINQ table get from the data context created on my SDF file.
ObservableCollection<MyTable> tempOperations = new ObservableCollection<MyTable>();
To initialize the GridView at program start I use this code
unsavedFormsGridView.ItemsSource = null;
tempOperations.Clear();
var temporaryOperations = from lto in dc.MyTable select lto;
foreach (MyTable item in temporaryOperations)
{
tempOperations.Add(item);
}
unsavedFormsGridView.ItemsSource = tempOperations;
Everything works fine and I can appreciate all data from the file into the GridView.
Very strange is the thing that happens lately, during a save process in which I write a new record that user input.
This process is started by a Button, different from those included in the gridview.
I create a new record and add it into the observable collection tempOperations in a code like this
private void buttonSaveTemporarly_Click(object sender, RoutedEventArgs e)
{
//Create the new record into currentOperation
BuildCurrentOperation();
dc.LandfillTempOperations.InsertOnSubmit(currentOperation);
dc.SubmitChanges();
unsavedFormsGridView.ItemsSource = null;
tempOperations.Add(currentOperation);
unsavedFormsGridView.ItemsSource = tempOperations;
//Set all the input controls to blank for the next new record
TempInitForm();
}
When the function terminates his job, the application does not respond to any input and more or less after 60 seconds appears the message
ContextSwitchDeadlock was detected
The CLR has been unable to transition from COM context 0x1fe3b0 to COM context 0x1fe520 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations
I must say that trying to understand more about this I have executed the application step by step.
At the end of the function VisualStudio 2008 asks to show a disassembly and in the address combobox of the disassembly window appears the following address
Telerik.Windows.Controls.GridView.BaseVirtualizingPanel.MeasureOverride(System.Windows.Size).
At this point my suspect is that there is something illegal I do in using GridView.
May anyone help me?
Thank you in advance
Nick
<
telerik:RadChart Width="299" Height="299" ItemsSource="{Binding Path=ConditionIndicatorDataPoints}">
<telerik:RadChart.DefaultView>
<telerik:ChartDefaultView>
<telerik:ChartDefaultView.ChartTitle>
<telerik:ChartTitle Content="{Binding Path=ChartName}" />
</telerik:ChartDefaultView.ChartTitle>
<telerik:ChartDefaultView.ChartLegend>
<telerik:ChartLegend Header="GDF"/>
</telerik:ChartDefaultView.ChartLegend>
<telerik:ChartDefaultView.ChartArea>
<telerik:ChartArea PlotAreaStyle="{StaticResource customStyle}">
<telerik:ChartArea.AxisY>
<telerik:AxisY Title="GDF" Visibility="Visible" AxisStyles="{DynamicResource customAxisTitleStyle}" />
</telerik:ChartArea.AxisY>
<telerik:ChartArea.AxisX>
<telerik:AxisX Title="OPTIME" Visibility="Visible" AxisStyles="{DynamicResource customAxisTitleStyle}" />
</telerik:ChartArea.AxisX>
</telerik:ChartArea>
</telerik:ChartDefaultView.ChartArea>
</telerik:ChartDefaultView>
</telerik:RadChart.DefaultView>
<telerik:RadChart.SeriesMappings>
<telerik:SeriesMapping>
<telerik:SeriesMapping.SeriesDefinition>
<telerik:LineSeriesDefinition />
</telerik:SeriesMapping.SeriesDefinition>
<telerik:SeriesMapping.ItemMappings>
<telerik:ItemMapping DataPointMember="YValue" FieldName="YPlotPoint" />
</telerik:SeriesMapping.ItemMappings>
</telerik:SeriesMapping>
</telerik:RadChart.SeriesMappings>
</telerik:RadChart>