Hello,
I'm trying to set up a RadGridView to display a RadEntityFrameworkCoreDataSource source using code-behind (currently a requirement) and cannot get the grid to populate with any data. I can access the data by using LINQ just fine, and can populate the grid using a ToList() version of that data, but I believe that it's just a copy of the data, and cannot be modified and saved to the original context.
Here's an example of what I'm trying to do:
var options = new DbContextOptionsBuilder<Test_Context>();
options.UseSqlServer(ConnectionString);
using var testContext= new Test_Context(options.Options);
RadEntityFrameworkCoreDataSource source = new()
{
Name = "coreDataSource",
DbContext = testContext,
QueryName = "TblCustomer"
};
// This doesn't populate the grid
rgvCustomers.ItemsSource = source.DataView;
// This populates the grid
var customerList = textContext.TblCustomer.Where(customer => customer.Id != -1).ToList();
rgvCustomers.ItemsSource = customerList ;
How do I get the RadEntityFrameworkCoreDataSource to query the data so that it can populate the grid?
Also, how would I go about only querying the customers with an Id != -1 using said Data Source? Is that as simple as setting the filters, then querying?
I'm new to this, so apologies if I've missed a simple step.
<telerik:RadAutoCompleteBox TextSearchMode="Contains" SelectedItem="{Binding Entity, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" DisplayMemberPath="Name" HorizontalAlignment="Stretch" SelectionMode="Single" Margin="125,100,0,10" VerticalAlignment="Top" Width="Auto" Grid.Column="0" Name="customerACB" SearchTextChanged="customerACB_SearchTextChanged" AutoCompleteMode="Suggest" >
<telerik:RadAutoCompleteBox.DropDownItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Code}" Width="70" />
<Label Content="{Binding Name}" Width="310" />
</StackPanel>
</DataTemplate>
</telerik:RadAutoCompleteBox.DropDownItemTemplate>
</telerik:RadAutoCompleteBox>
Currently, i am able to search using "Name". If I change displaymemberpath to code it will show the result if the search string match with "code"
I need to search using both values "Name" and "code".
Hi -
I have a RadGridView that populates dynamically based on columns present in an Excel spread-sheet. I'm able to create the columns but not having luck getting the ToolTip to display.
Thanks in advance - Jon
Here is my code snippet:
foreach (DataColumn column in dt.Columns)
{
Telerik.Windows.Controls.GridViewDataColumn gridviewDataColumn = new Telerik.Windows.Controls.GridViewDataColumn
{
Header = column.ColumnName,
Name = column.ColumnName,
DataMemberBinding = new System.Windows.Data.Binding(column.ColumnName),
// Tooltip = ???
};
dtg_PreviewMapGrid.Columns.Add(gridviewDataColumn);
}
dtg_PreviewMapGrid.ItemsSource = dt;
<telerik:RadTaskBoard x:Name="RadTaskBoard01" Grid.Row="3"
ItemsSource="{Binding TaskboardCollView}"
GroupMemberPath="State"
Background="{StaticResource StripeColor}"
AutoGenerateColumns="False">
<telerik:RadTaskBoard.DragDropBehavior>
<localservice:CustomTaskBoardDragDropBehavior/>
</telerik:RadTaskBoard.DragDropBehavior>
<telerik:RadTaskBoard.Columns>
<telerik:TaskBoardColumn GroupName="NEW" Header="Red" />
<telerik:TaskBoardColumn GroupName="INPROGRESS" Header="Yellow" />
<telerik:TaskBoardColumn GroupName="REVIEWED" Header="Gray" />
<telerik:TaskBoardColumn GroupName="DONE" Header="ForestGreen" />
</telerik:RadTaskBoard.Columns>
<telerik:RadTaskBoard.ColumnHeaderTemplate >
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions >
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Border Width="17" Grid.Column="0" Background ="{Binding Header}" BorderThickness="1" BorderBrush="Black" CornerRadius="10" ></Border>
<TextBlock Grid.Column="1" Text="{Binding GroupName}" HorizontalAlignment="Left" />
<TextBlock Grid.Column="2" Margin="10 ,0 ,10, 0" Text="{Binding Items.Count}" HorizontalAlignment="Right" />
</Grid>
</DataTemplate>
</telerik:RadTaskBoard.ColumnHeaderTemplate>
<telerik:RadTaskBoard.ItemTemplate>
<DataTemplate>
<Grid >
<Grid.ColumnDefinitions >
<ColumnDefinition Width="5"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions >
<RowDefinition/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.RowSpan="2" Grid.Column ="0"
Background="{Binding CategoryName, Converter={StaticResource CategoryToColour}}">
</Grid>
<StackPanel Grid.Row="0" Grid.Column ="1" >
<TextBlock Text="{Binding Parenttitle}" Margin="15,0,5,0" Foreground="{StaticResource StripeColor}" FontSize="16" TextWrapping="Wrap" />
<StackPanel Visibility="{Binding Isparent, Converter={StaticResource BoolToVisible}}">
<TextBlock Text="Have Sub Task"
HorizontalAlignment="Right"
Margin="0,0,5,0"
Foreground="Red"
FontWeight="Bold"
FontStyle ="Italic"
FontSize="12" />
</StackPanel>
<StackPanel Visibility="{Binding Title, Converter={StaticResource EmptyToVisible }}">
<TextBlock Text="{Binding Title}"
Margin="15,0,5,0"
Foreground="Brown"
TextWrapping="WrapWithOverflow"
FontSize="14" />
</StackPanel>
<TextBlock Text="{Binding Description}"
Margin="15,0,5,0"
TextWrapping="Wrap"
FontSize="14" />
</StackPanel>
<TextBlock Text="{Binding Assignee}" Grid.Row="1" Grid.Column ="1" Margin="15,0,15,0" Foreground="ForestGreen"
FontSize="16" FontStyle="Italic" HorizontalAlignment="Right" VerticalAlignment="Bottom" />
</Grid>
</DataTemplate>
</telerik:RadTaskBoard.ItemTemplate>
</telerik:RadTaskBoard>
Hello!
I want to change DrageVisual Template in OnGiveFeedback event instead of set e.SetCursor(Cursors.Cross); Is it possible?
private void OnDragInitialize(object sender, DragInitializeEventArgs e)
{
e.DragVisual =new ContentControl { Name = "DragVisual", ContentTemplate =
this.AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate, DataContext = items.Count() };
e.DragVisualOffset = e.RelativeStartPoint;
e.AllowedEffects = DragDropEffects.All;
e.Handled = true;
}
}
private void OnGiveFeedback(object sender, Telerik.Windows.DragDrop.GiveFeedbackEventArgs e)
{
if (e.Effects == DragDropEffects.Move)
{
e.UseDefaultCursors = false;
e.SetCursor(Cursors.Arrow);
}
else if (e.Effects == DragDropEffects.None)
{
e.UseDefaultCursors = false;
e.SetCursor(Cursors.Cross);
}
else
{
e.UseDefaultCursors = true;
}
e.Handled = true;
}
How do I bind the DateTime Property (return value for GetDateTime())
of a class implementing ITimeIndicator to a Property of my ViewModel?
my thoughts:
<telerik:RadScheduleView.TimeIndicatorsCollection>
<telerik:TimeIndicatorsCollection>
<local:CustomTimeIndicator Location="WholeArea" Now="{Binding CurrentNow}" />
</telerik:TimeIndicatorsCollection>
</telerik:RadScheduleView.TimeIndicatorsCollection>
public class CustomTimeIndicator : DependencyObject, ITimeIndicator
{
public static readonly DependencyProperty NowProperty = DependencyProperty.RegisterAttached("Now", typeof(DateTime), typeof(CustomTimeIndicator));
public DateTime Now
{
get => (DateTime)GetValue(NowProperty);
set => SetValue(NowProperty, value);
}
public DateTime GetDateTime()
{
return Now;
}
public TimeSpan Offset { get; set; }
public CurrentTimeIndicatorLocation Location { get; set; }
}
Gives me:
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=CurrentNow; DataItem=null; target element is 'CustomTimeIndicator' (HashCode=47896050); target property is 'Now' (type 'DateTime')
Hello:
About the RadDateTimePicker,
when I set the telerik:ValidationErrorTemplateHelper.ShowWhenFocused = "True"
It only doesn't work on Theme="Expression_Dark".
The others themes seems no problem.
Hi,
editor.TextFormatDefinitions.AddLast("Brace", new TextFormatDefinition(null, Brushes.Black));
...
MultilineTags.Add(new TagSpan<ClassificationTag>(tempSnapshotSpan, new ClassificationTag(new ClassificationType("Brace"))));
Nothing special - RadSyntaxEditor and those two lines in WPF. Foreground is working very well - I can highlight any part of my text as I wish. But border and background does not working ... And also unwanted behavior - foreground of other highlighting is reset when I try highlight by background change... Even just border highlighting would be sufficient ... (I want highlight closest braces.)
Update:
Working brace content highlighter:
internal class ExpressionTagger : CSharpTagger
{
const string
openBraces = "([{",
closeBraces = ")]}";
new RadSyntaxEditor Editor => (RadSyntaxEditor)base.Editor;
public ExpressionTagger(RadSyntaxEditor editor) : base(editor)
{
editor.TextFormatDefinitions.AddLast("Class", new TextFormatDefinition(new SolidColorBrush(Color.FromRgb(43, 145, 175))));
editor.TextFormatDefinitions.AddLast("Brace", new TextFormatDefinition(new SolidColorBrush(Color.FromRgb(155, 83, 105))));
AddWord("Field", new ClassificationType("Class"));
AddWord("Custom", new ClassificationType("Class"));
AddWord("Triggers", new ClassificationType("Class"));
StringMatchingRegex = String.Empty; // Nemá smysl, neumí najít co chceme.
editor.CaretPosition.PositionChanged += CaretPosition_PositionChanged;
editor.KeyDown += CaretPosition_PositionChanged;
editor.KeyUp += CaretPosition_PositionChanged;
}
private void CaretPosition_PositionChanged(object sender, EventArgs e)
{
if (Editor.CaretPosition.Index < Document.CurrentSnapshot.Span.End)
{
char currentChar = Document.CurrentSnapshot.GetText(new Span(Editor.CaretPosition.Index, 1))[0];
if (MultilineTags.Any(tag => tag.Tag.ClassificationType.Name == "Brace") ||
(KeyboardModifiers.IsAltDown && (openBraces.Contains(currentChar) || closeBraces.Contains(currentChar))))
{
InvalidateMultilineTags();
}
}
}
protected override void RebuildMultilineTags()
{
base.RebuildMultilineTags();
string text = Editor.Document.CurrentSnapshot.GetText();
foreach (Match literal in Regex.Matches(text, "\"(?:[^\"]|\"{2})*\""))
{
TextSnapshotSpan tempSnapshotSpan = new TextSnapshotSpan(Document.CurrentSnapshot,
new Span(literal.Groups[0].Index, literal.Groups[0].Length));
MultilineTags.Add(new TagSpan<ClassificationTag>(tempSnapshotSpan, new ClassificationTag(ClassificationTypes.StringLiteral)));
}
if (KeyboardModifiers.IsAltDown)
{
int
startIndex = Editor.CaretPosition.Index,
searchIndex = 1,
closeIndex = 0;
char currentChar = Document.CurrentSnapshot.GetText(new Span(Editor.CaretPosition.Index, 1))[0];
int braceIndex = openBraces.IndexOf(currentChar);
if (braceIndex > -1)
{
char
openBrace = currentChar,
closeBrace = closeBraces[braceIndex];
closeIndex = startIndex + 1;
while (searchIndex > 0 && closeIndex < text.Length)
{
currentChar = text[closeIndex];
if (currentChar == openBrace)
{
searchIndex++;
}
if (currentChar == closeBrace)
{
searchIndex--;
}
closeIndex++;
}
closeIndex--;
currentChar = char.MinValue; // reset
}
braceIndex = closeBraces.IndexOf(currentChar);
if (braceIndex > -1)
{
char
openBrace = openBraces[braceIndex],
closeBrace = currentChar;
closeIndex = startIndex;
startIndex--;
while (searchIndex > 0 && startIndex > 0)
{
currentChar = text[startIndex];
if (currentChar == closeBrace)
{
searchIndex++;
}
if (currentChar == openBrace)
{
searchIndex--;
}
startIndex--;
}
startIndex++;
}
if (searchIndex == 0) // Found
{
TextSnapshotSpan tempSnapshotSpan = new TextSnapshotSpan(Document.CurrentSnapshot,
new Span(startIndex, closeIndex - startIndex + 1));
MultilineTags.Add(new TagSpan<ClassificationTag>(tempSnapshotSpan, new ClassificationTag(new ClassificationType("Brace"))));
}
}
}
}