or
Tree.AddHandler(RadDragAndDropManager.DragQueryEvent,
new
EventHandler<DragDropQueryEventArgs>(Tree_DragQuery),
true
);
private
void
Tree_DragQuery(
object
sender, DragDropQueryEventArgs e)
{
var targetTvi = e.Options.Destination
as
RadTreeViewItem;
var sourceTvi = e.Options.Source
as
RadTreeViewItem;
if
(targetTvi ==
null
|| sourceTvi ==
null
)
{
return
;
}
if
(sourceTvi.DataContext
is
LayerTviVM && targetTvi.DataContext
is
LayerTviVM)
{
e.QueryResult =
true
;
}
else
if
(sourceTvi.DataContext
is
ImageTviVM && targetTvi.DataContext
is
ImageTviVM)
{
// We only support drag & drop of images within the same layer
e.QueryResult = (sourceTvi.ParentItem == targetTvi.ParentItem);
}
else
{
e.QueryResult =
false
;
}
}
System.Nullable<double> property, I have a couple issues. One issue is that it allows the user to type anything in the field. Not just decimal numbers. I tried to solve this by using cell validating, but when I type a character and tab out of the field, before validating fires it tries to update the bound item (2 way binding is on) and throws a format exception because the character value cannot be put into the double? property.
The other issue is, since it is nullable, I would also like to allow the user to leave the field blank and it assign null to the bound property. Is this possible or am I going to have to unbind the column and manually update accordingly?
<
telerik:RadCartesianChart
x:Name
=
"chart"
Grid.Column
=
"0"
>
<
telerik:RadCartesianChart.Series
>
<
telerik:BarSeries
ItemsSource
=
"{Binding DataItems}"
ValueBinding
=
"Value"
CategoryBinding
=
"DayPeriod"
>
<
telerik:BarSeries.PointTemplate
>
<
DataTemplate
>
<
Rectangle
Fill
=
"{Binding Converter={StaticResource BrushConverter}, ConverterParameter={StaticResource brushes}}"
/>
</
DataTemplate
>
</
telerik:BarSeries.PointTemplate
>
</
telerik:BarSeries
>
</
telerik:RadCartesianChart.Series
>
<
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:LinearAxis
Minimum
=
"{Binding MinValue}"
Maximum
=
"{Binding MaxValue}"
MajorStep
=
"{Binding StepSize}"
LabelStyle
=
"{StaticResource axisLabelStyle}"
/>
</
telerik:RadCartesianChart.VerticalAxis
>
<
telerik:RadCartesianChart.HorizontalAxis
>
<
telerik:CategoricalAxis
LabelFitMode
=
"Rotate"
LabelInterval
=
"2"
/>
</
telerik:RadCartesianChart.HorizontalAxis
>
</
telerik:RadCartesianChart
>
<
telerik:RadGridView
Name
=
"GridViewMyGrid"
ItemsSource
=
"{Binding MyCollection}"
AutoGenerateColumns
=
"False"
IsReadOnly
=
"True"
CanUserFreezeColumns
=
"False"
GroupRenderMode
=
"Flat"
ShowColumnFooters
=
"True"
ShowGroupFooters
=
"True"
AutoExpandGroups
=
"True"
IsFilteringAllowed
=
"False"
ShowGroupPanel
=
"False"
FrozenColumnCount
=
"2"
SelectionMode
=
"Extended"
>
<
telerik:RadGridView.ColumnGroups
>
<
telerik:GridViewColumnGroup
Name
=
"Group1ColumnGroup"
Header
=
"Group1"
>
<
telerik:GridViewColumnGroup.HeaderTemplate
>
<
DataTemplate
>
<
TextBlock
Text
=
"Group1"
TextAlignment
=
"Center"
FontWeight
=
"Bold"
></
TextBlock
>
</
DataTemplate
>
</
telerik:GridViewColumnGroup.HeaderTemplate
>
</
telerik:GridViewColumnGroup
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding GroupName}"
ShowColumnWhenGrouped
=
"False"
/>
<
telerik:GridViewDataColumn
Header
=
"Item1"
DataMemberBinding
=
"{Binding Item1}"
>
<
telerik:GridViewDataColumn.AggregateFunctions
>
<
telerik:FirstFunction
/>
</
telerik:GridViewDataColumn.AggregateFunctions
>
<
telerik:GridViewDataColumn.GroupFooterTemplate
>
<
DataTemplate
>
<
TextBlock
FontWeight
=
"Bold"
>
<
Run
Text
=
"Subtotal "
/>
<
Run
Text
=
"{Binding Value.GroupName}"
/>
</
TextBlock
>
</
DataTemplate
>
</
telerik:GridViewDataColumn.GroupFooterTemplate
>
<
telerik:GridViewColumn.Footer
>
<
TextBlock
FontWeight
=
"Bold"
>
<
Run
Text
=
"Asset Total"
/>
</
TextBlock
>
</
telerik:GridViewColumn.Footer
>
</
telerik:GridViewDataColumn
>
private
void
ButtonExportStrats_OnClick(
object
sender, RoutedEventArgs e)
{
var grid = GridViewMyGrid;
var dialog =
new
SaveFileDialog();
dialog.DefaultExt =
"*.xlsx"
;
dialog.Filter =
"Excel Workbook (*.xlsx)|*.xlsx"
;
if
(dialog.ShowDialog() ==
true
)
{
Workbook book =
null
;
using
(var stream =
new
MemoryStream())
{
grid.Export(stream,
new
GridViewExportOptions()
{
Format = ExportFormat.Csv,
ShowColumnFooters = grid.ShowColumnFooters,
ShowColumnHeaders = grid.ShowColumnHeaders,
ShowGroupFooters = grid.ShowGroupFooters
});
stream.Position = 0;
book =
new
CsvFormatProvider().Import(stream);
if
(book !=
null
)
{
var provider =
new
XlsxFormatProvider();
using
(var output = dialog.OpenFile())
{
provider.Export(book, output);
}
}
}
}
}