<Window
x:Class
=
"TelerikExample.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
Window.Resources
>
<
DataTemplate
x:Key
=
"dtFirstName"
>
<
TextBox
Text
=
"{Binding Path=FirstName, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}"
/>
</
DataTemplate
>
<
DataTemplate
x:Key
=
"dtSecondName"
>
<
TextBox
Text
=
"{Binding Path=SecondName, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True}"
/>
</
DataTemplate
>
</
Window.Resources
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"*"
/>
</
Grid.RowDefinitions
>
<
telerik:RadGridView
Grid.Row
=
"1"
CanUserDeleteRows
=
"False"
CanUserInsertRows
=
"False"
CanUserSortColumns
=
"False"
ShowGroupPanel
=
"False"
AutoGeneratingColumn
=
"RadGridView_AutoGeneratingColumn"
ItemsSource
=
"{Binding Rows}"
RowIndicatorVisibility
=
"Collapsed"
AlternateRowBackground
=
"White"
AlternationCount
=
"2"
Background
=
"AliceBlue"
EditTriggers
=
"None"
HorizontalGridLinesBrush
=
"SlateGray"
SelectionMode
=
"Single"
SelectionUnit
=
"FullRow"
ShowColumnHeaders
=
"True"
IsFilteringAllowed
=
"False"
VerticalGridLinesBrush
=
"Transparent"
>
</
telerik:RadGridView
>
</
Grid
>
</
Window
>
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Data;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Imaging;
using
System.Windows.Navigation;
using
System.Windows.Shapes;
namespace
TelerikExample
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public
partial
class
MainWindow : Window
{
private
GridViewModel _viewModel;
public
MainWindow()
{
InitializeComponent();
_viewModel =
new
GridViewModel();
this
.DataContext = _viewModel;
}
private
void
RadGridView_AutoGeneratingColumn(
object
sender, Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs e)
{
if
(e.Column.UniqueName ==
"FirstName"
)
{
e.Column.CellTemplate = (DataTemplate)
this
.Resources[
"dtFirstName"
];
e.Column.Header =
"Forename"
;
}
else
if
(e.Column.UniqueName ==
"SecondName"
)
{
e.Column.CellTemplate = (DataTemplate)
this
.Resources[
"dtSecondName"
];
e.Column.Header =
"Surname"
;
}
else
if
(e.Column.UniqueName ==
"ViewModel"
)
{
e.Column.IsVisible =
false
;
}
}
}
}
namespace
TelerikExample
{
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.ComponentModel;
using
System.Dynamic;
using
System.Collections.ObjectModel;
public
class
GridViewModel : INotifyPropertyChanged
{
public
event
PropertyChangedEventHandler PropertyChanged;
private
ObservableCollection<dynamic> _rows;
/// <summary>
///
/// </summary>
/// <param name="name"></param>
protected
void
OnPropertyChanged(
string
name)
{
if
(PropertyChanged !=
null
)
{
PropertyChanged(
this
,
new
PropertyChangedEventArgs(name));
}
}
public
GridViewModel()
{
_rows =
new
ObservableCollection<dynamic>();
var row =
new
ExpandoObject()
as
IDictionary<
string
, Object>;
row.Add(
"FirstName"
,
string
.Empty);
row.Add(
"SecondName"
,
string
.Empty);
row.Add(
"ViewModel"
,
this
);
((INotifyPropertyChanged)row).PropertyChanged +=
new
PropertyChangedEventHandler(TelerikExample.PropertyChanged.Row_PropertyChanged);
_rows.Add(row);
}
public
void
CheckForNewRow()
{
IDictionary<
string
, Object> lastRow = _rows.Last()
as
IDictionary<
string
, Object>;
if
(((
string
)lastRow[
"FirstName"
]) !=
string
.Empty || ((
string
)lastRow[
"SecondName"
]) !=
string
.Empty)
{
//Add new row
var row =
new
ExpandoObject()
as
IDictionary<
string
, Object>;
row.Add(
"FirstName"
,
string
.Empty);
row.Add(
"SecondName"
,
string
.Empty);
row.Add(
"ViewModel"
,
this
);
((INotifyPropertyChanged)row).PropertyChanged +=
new
PropertyChangedEventHandler(TelerikExample.PropertyChanged.Row_PropertyChanged);
this
.Rows.Add(row);
}
}
public
ObservableCollection<dynamic> Rows
{
get
{
return
_rows;
}
set
{
if
(_rows != value)
{
_rows = value;
OnPropertyChanged(
"Rows"
);
}
}
}
}
}
namespace
TelerikExample
{
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.ComponentModel;
using
System.Dynamic;
public
class
PropertyChanged
{
public
static
void
Row_PropertyChanged(
object
sender, PropertyChangedEventArgs e)
{
object
value;
((IDictionary<
string
, Object>)sender).TryGetValue(
"ViewModel"
,
out
value);
GridViewModel vm = (GridViewModel)value;
vm.CheckForNewRow();
}
}
}
I have the below code attached to a SelectionChanged event in a WPF RichTextBox. The idea is for it to select the sentence the user is currently editing, a la iAWriter. Any ideas why it only selects past the cursor, or occasionally throws a ArgumentNullException? Thanks in advance.
Regex sentence = new Regex(@"(([.?!][^\s])*[^.?!])*[.?!]\s");
Regex srtl = new Regex(@"(?:[.?!]\s)(([.?!][^\s])*[^.?!])*", RegexOptions.RightToLeft);
TextRange all = new TextRange(GetPoint(inp.Document.ContentStart, 0), GetPoint(inp.Document.ContentEnd, 0));
TextRange aa = new TextRange(GetPoint(inp.Document.ContentStart, 0), GetPoint(inp.CaretPosition, 0));
TextRange ab = new TextRange(GetPoint(inp.CaretPosition, 0), GetPoint(inp.Document.ContentEnd, 0));
Match b = srtl.Match(aa.Text);
Match c = sentence.Match(ab.Text);
TextRange cur = new TextRange(GetPoint(inp.CaretPosition, -b.Index), GetPoint(inp.CaretPosition.GetPositionAtOffset(c.Index + c.Length + b.Length), 0));
all.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Silver);
cur.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White);
I created a proj based on your class diagram example. I wanted to extend this example to save and reload the layout from disk. I called the diagram Save method and this is the Xml returned (I have removed some attributes for clarity). My question is when I call diagram Load, how do I re-attach the Model objects to the shapes in the diagrams? From the Xml below I can see a Shapes content contains the class name of the Model (MyProj.ClassViewModel) that represents that shape. Do I have to iterate all of the Shapes and set their content? If so how can I get this xml to store a key for the instance of the model a shape it contains.
Thanks Craig.
<?xml version="1.0" encoding="utf-8"?>
<RadDiagram Type="Telerik.Windows.Diagrams.Core.IGraphInternal" Version="2012.1">
<Metadata Id="601d134b-3a2c-4055-9f7f-78d70597b052" >
<Title><![CDATA[Diagram [4/12/2012 8:44:45 AM]]]></Title>
<Description><![CDATA[]]></Description>
<Background>#00FFFFFF</Background>
</Metadata> <Shapes QNs="Telerik.Windows.Controls.Diagrams, Version=2012.1.326.40, Culture=neutral, PublicKeyToken=5803cfa389c90ce7;"> <RadDiagramShape Type="Telerik.Windows.Controls.RadDiagramShape" Id="4b632971-9f11-41a8-88b4-67992258e376" Content="MyProj.ClassViewModel" Geometry="M0,0L60,0 60,40 0,40z" QN="0" /> </Shapes>
<Connections />
</RadDiagram>
error MC3064: Only public or internal classes can be used within markup. 'Style' type is not public or internal.
Below is the xaml that caused the errors.
<
telerik:GridViewCheckBoxColumn.HeaderCellStyle
>
<
Style
TargetType
=
"{x:Type telerik:GridViewHeaderCell}"
>
<
Style.Setters
>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"{x:Type telerik:GridViewHeaderCell}"
>
<
telerik:GridViewHeaderCell
FilteringUIVisibility
=
"Collapsed"
>
<
StackPanel
HorizontalAlignment
=
"Center"
Margin
=
"5"
>
<
ContentPresenter
HorizontalAlignment
=
"Center"
VerticalAlignment
=
"Center"
/>
<
CheckBox
x:Name
=
"CheckBoxHeaderTemplate"
HorizontalAlignment
=
"Center"
Margin
=
"0,5,0,0"
Checked
=
"CheckBoxHeader_Checked"
Unchecked
=
"CheckBoxHeader_Checked"
/>
</
StackPanel
>
</
telerik:GridViewHeaderCell
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style.Setters
>
</
Style
>
</
telerik:GridViewCheckBoxColumn.HeaderCellStyle
>
<
telerik:GridViewDataColumn.HeaderCellStyle
>
<
Style
TargetType
=
"{x:Type telerik:GridViewHeaderCell}"
>
<
Style.Setters
>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"{x:Type telerik:GridViewHeaderCell}"
>
<
ContentPresenter
HorizontalAlignment
=
"Stretch"
/>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style.Setters
>
</
Style
>
</
telerik:GridViewDataColumn.HeaderCellStyle
>
<
telerik:GridViewCheckBoxColumn.CellStyle
>
<
Style
TargetType
=
"telerik:GridViewCell"
>
<
Setter
Property
=
"HorizontalContentAlignment"
Value
=
"Center"
/>
</
Style
>
</
telerik:GridViewCheckBoxColumn.CellStyle
>
Any help would be greatly appreciated.
Thanks in advance,
Steve
<StatusBar DockPanel.Dock="Bottom" telerik:StyleManager.Theme="Office_Blue"> |
<StatusBar.ItemsPanel> |
<ItemsPanelTemplate> |
<Grid> |
<Grid.ColumnDefinitions> |
<ColumnDefinition Width="*"/> |
<ColumnDefinition Width="Auto"/> |
</Grid.ColumnDefinitions> |
</Grid> |
</ItemsPanelTemplate> |
</StatusBar.ItemsPanel> |
<TextBlock>Left Side</TextBlock> |
<StatusBarItem Grid.Column="1"> |
<TextBlock>Right Side</TextBlock> |
</StatusBarItem> |
</StatusBar> |
Hi,
I followed more or less the example "Special and Read-only Slots"
in order to achieve the desired behavior (show working hours in a different color).
As you can see in the first screen shot (sched01.png), everything works fine.
As soon as I use custom grouping, the working hours are no more visible (see sched02.png).
After deselecting the group item (here: Zimmer 315), the working hours for the selected person are displayed again.
Your help is highly appreciated.
Regards,
Daniel