Telerik Forums
UI for WPF Forum
2 answers
404 views
Hello,

I create dynamically my columns through an attached property and can't seem to set the string format for my columns. I would like my number have the format 1234.00 > 1,234.00

How to do that ?

I tried with:
in my .xaml:

<telerik:RadGridView  x:Name="RadGridView1"    
                              ItemsSource="{Binding ResultsViewModelList}" AutoGenerateColumns="False"  
                              custom:GridViewDataColumnsBehavior.BindableColumns="{Binding ColumnCollection}"
...
    
in my view model :
 // Toggle Column
GridViewToggleRowDetailsColumn gridRowToggle = new GridViewToggleRowDetailsColumn();
ColumnCollection.Add(gridRowToggle);

//data column
GridViewDataColumn column =
new GridViewDataColumn();
 string columnName = "column1";
 column.Header = columnName;
 column.UniqueName = columnName;
 column.DataMemberBinding = new Binding("ResultDataDictionary[" + columnName + "]");
 column.DataMemberBinding.StringFormat = "0:N"//also tried with N , {0:N}, ...
//also tried > column.DataFormatString = "0:N";
 column.DataType = typeof(double);
 
ColumnCollection.Add(column);

in GridViewDataColumnsBehavior:

public static readonly DependencyProperty BindableColumnsProperty =
            DependencyProperty.RegisterAttached("BindableColumns",
                                                typeof(ObservableCollection<GridViewColumn>),
                                                typeof(GridViewDataColumnsBehavior),
                                                new UIPropertyMetadata(null, BindableColumnsPropertyChanged));
 
        private static void BindableColumnsPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            RadGridView RadGridView = source as RadGridView;
            ObservableCollection<GridViewColumn> columns = e.NewValue as ObservableCollection<GridViewColumn>;
            RadGridView.Columns.Clear();
            if (columns == null)
            {
                return;
            }
            foreach (GridViewColumn column in columns)
            {
                RadGridView.Columns.Add(column);
            }
 
.....

Dimitrina
Telerik team
 answered on 10 Nov 2014
1 answer
818 views
I want to bind a RadGridView and a RadDataForm to the same collection of items and they should synchronize like in your WPF demo application. When I bind the ItemsSource property directly to my ICollectionView property in the ViewModel everything works fine. But when I create a CollectionViewSource bound to that property and use this resource as ItemsSource both controls do not show the data. Why is that not possible? I want to add sorting and grouping and CollectionViewSource seems to be the right way. Here's my code:

​
01.<Window x:Class="WpfApplication1.MainWindow"
04.        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
05.        Title="MainWindow">
06.    <Window.Resources>
07.        <CollectionViewSource x:Key="MySource" Source="{Binding ItemsView}" />
08.    </Window.Resources>
09.    <Grid>
10.        <StackPanel>
11.            <StackPanel Orientation="Horizontal" Height="200" Margin="10">
12.                <!-- binding directly to property ItemsView in DataContext/ViewModel ... WORKING -->
13.                <telerik:RadGridView AutoGenerateColumns="True" ItemsSource="{Binding ItemsView}" Width="200" />
14.                <telerik:RadDataForm AutoGenerateFields="True" ItemsSource="{Binding ItemsView}" Width="200" />
15.            </StackPanel>
16.            <StackPanel Orientation="Horizontal" Height="200" Margin="10">
17.                <!-- binding to CollectionViewSource ... NOT working -->
18.                <telerik:RadGridView AutoGenerateColumns="True" ItemsSource="{Binding Source={StaticResource MySource}}" Width="200" />
19.                <telerik:RadDataForm AutoGenerateFields="True" ItemsSource="{Binding Source={StaticResource MySource}}" Width="200" />
20.            </StackPanel>
21.        </StackPanel>
22.    </Grid>
23.</Window>
Dimitrina
Telerik team
 answered on 07 Nov 2014
5 answers
343 views
I have DB table Vehicle and I am using EF4. So I got a partial class Vehicle to map with the db table.
Vehicle is a master table. It has a detail table Fault.  1 vehicle could have many faults.

I am trying to get the count of fault associated with vehicle. So I created one customized property for Vehicle class. FaultCount.

Partial Class Vehicle
{

    public global::System.Int32 FaultCount
        {
            get
            {
                CCF20Entities ccf20Ent = new CCF20Entities();
                return ccf20Ent.Faults.Where(f => f.IsActive && f.FaultType == "Vehcile" && f.VehicleID== this.VehicleID).Count();
            }

        }

}
Everything works fine. I got the data I want and populate the grid. But when I try to sort the column, I get the exception.

"The specified type member 'FaultCount' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported."

Any help?

Thx,
David
Dimitrina
Telerik team
 answered on 07 Nov 2014
1 answer
205 views
hi,
when i try to add custom items such as textblocks, ellipse, rectangles or any ui element, they are rendered verticaly,
although i'm using the verticale scale.
I couldn't find any property in the style that can tell the scale to show them horizontaly, like the tick marks embeded directly in the vertical scale.

this is my example:
<Window x:Class="Gauge.MainWindow"
        xmlns:local="clr-namespace:Gauge"
        Title="MainWindow"
        Width="525"
        Height="500">
    <Window.Resources>
        <Style TargetType="{x:Type telerik:Marker}">
            <Setter Property="telerik:ScaleObject.Location" Value="Outside" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type telerik:Marker}">
                        <StackPanel Orientation="Horizontal">
                            <Border HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    BorderBrush="{TemplateBinding Background}"
                                    BorderThickness="2">
                                <TextBlock Width="28.5"
                                           Background="{TemplateBinding Background}"
                                           Foreground="Black"
                                           Opacity="0.5"
                                           Padding="2,0"
                                           Text="{Binding Value,
                                                          RelativeSource={RelativeSource TemplatedParent}}" />
                            </Border>
                            <Rectangle Width="10"
                                       Height="2"
                                       VerticalAlignment="Center"
                                       Fill="{TemplateBinding Background}" />
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid Background="AliceBlue">
        <telerik:RadVerticalLinearGauge Grid.Row="1"
                                        Grid.Column="1"
                                        Width="100"
                                        Height="250"
                                        OuterBackground="Azure"
                                        OuterBorderBrush="Black"
                                        telerik:StyleManager.Theme="Windows8">
            <telerik:RadVerticalLinearGauge.Resources>
                <Style x:Key="CustomTick" TargetType="Ellipse">
                    <Setter Property="Fill" Value="White" />
                    <Setter Property="Width" Value="5" />
                    <Setter Property="Height" Value="5" />
                    <Setter Property="telerik:ScaleObject.Location" Value="CenterInside" />
                    <Setter Property="Canvas.ZIndex" Value="1001" />
                </Style>
                <Style x:Key="CustomTickLine" TargetType="Rectangle">
                    <Setter Property="telerik:ScaleObject.RelativeHeight" Value="0.07*" />
                    <Setter Property="Width" Value="1" />
                    <Setter Property="telerik:ScaleObject.Location" Value="CenterOutside" />
                    <Setter Property="Canvas.ZIndex" Value="1001" />
                </Style>
            </telerik:RadVerticalLinearGauge.Resources>
            <telerik:VerticalLinearScale IsInteractive="True"
                                         LabelUseRangeColor="True"
                                         Max="4500"
                                         Min="0">
                <telerik:VerticalLinearScale.Ranges>
                    <telerik:GaugeRange IndicatorBackground="Red"
                                        LabelForeground="Red"
                                        Max="2000"
                                        Min="0"
                                        TickBackground="Red" />
                    <telerik:GaugeRange IndicatorBackground="Green"
                                        LabelForeground="Green"
                                        Max="4500"
                                        Min="2000"
                                        TickBackground="Green" />
                </telerik:VerticalLinearScale.Ranges>
                <telerik:VerticalLinearScale.Indicators>
                    <telerik:BarIndicator x:Name="barIndicator_main"
                                          RangeColorMode="Default"
                                          UseRangeColor="True"
                                          Value="4200" />
                    <telerik:Marker UseRangeColor="True"
                                    telerik:ScaleObject.Offset="15"
                                    telerik:ScaleObject.RelativeHeight="20"
                                    telerik:ScaleObject.RelativeWidth="40"
                                    Value="{Binding Value,
                                                    ElementName=barIndicator_main}">
                        <telerik:Marker.LayoutTransform>
                            <RotateTransform Angle="90" CenterX="0.5" CenterY="0.5" />
                        </telerik:Marker.LayoutTransform>
                    </telerik:Marker>
                </telerik:VerticalLinearScale.Indicators>
                <telerik:VerticalLinearScale.CustomItems>
                    <Ellipse Stroke="Red"
                             Style="{StaticResource CustomTick}"
                             telerik:ScaleObject.Value="0">
                        <!--<Ellipse.LayoutTransform>
                            <RotateTransform Angle="90" CenterX="0.5" CenterY="0.5" />
                        </Ellipse.LayoutTransform>-->
                    </Ellipse>
                    <Rectangle Fill="Red"
                               Style="{StaticResource CustomTickLine}"
                               telerik:ScaleObject.Value="0">
                        <!--<Rectangle.LayoutTransform>
                            <RotateTransform Angle="90" CenterX="0.5" CenterY="0.5" />
                        </Rectangle.LayoutTransform>-->
                    </Rectangle>
 
                    <!--
                        <TextBlock FontWeight="Bold"
                        Foreground="Red"
                        Text="2000"
                        telerik:ScaleObject.Location="Outside"
                        telerik:ScaleObject.Value="2000" />
                    -->
                </telerik:VerticalLinearScale.CustomItems>
            </telerik:VerticalLinearScale>
 
        </telerik:RadVerticalLinearGauge>
    </Grid>
</Window>

Thanks.
Sia
Telerik team
 answered on 07 Nov 2014
3 answers
195 views
is it possible to create and call the radial menu just straight from code ?
Yana
Telerik team
 answered on 07 Nov 2014
3 answers
210 views
Hi,

can anyone tell me if there is an event to detect when just before the "highlightbehavior" and the "filteringbehavior" will be invoke?

Thank's
Alain
Nasko
Telerik team
 answered on 07 Nov 2014
1 answer
223 views
Hi there, im trying to do a text range on a RadRichTextBox is there anyway to get the Document ContentStart?  e.g

TextRange range = new TextRange(RadRichTextBox.Document.ContentStart, CaretPosition);

Petya
Telerik team
 answered on 07 Nov 2014
1 answer
201 views
Hi,
Let me try to explain my issue. In our gridview some columns are bound to GUID properties in view model where we display the corresponding string value of the respective guid via implementing a custom gridview bound column (let's say instead of displaying the categoryId, we display the category name). Hence, user wants to filter the grid view by typing the name of the category but the filter editor is not visible since the bound type is guid (that's what I understand from the documentation), only the distinct filter is visible to the user. I have overcome this issue by overriding the CreateFieldFilterEditor method like so

public override FrameworkElement CreateFieldFilterEditor()
{
            TextBox searchTextBox = new TextBox();
            Binding searchTextBinding = new Binding("Value");
            searchTextBinding.Mode = BindingMode.TwoWay;
            searchTextBinding.FallbackValue = null;
            searchTextBox.SetBinding(TextBox.TextProperty, searchTextBinding);
            return searchTextBox;
}

Now I have two problems, first of all when I click on Filter button, nothing happens. What I expect is either the gridview filtering event is fired or get an exception with not being able to convert the string to guid. But, nothing happens. What might be the reason that stops filtering even firing?

Secondly, I only have "Is Equal To", "Is Not Equal To", "Is Null" and "IsNot null" as available filter operators. But I also need Contains, Starts With etc.
I dont know where to start. I have been looking at the Custom Filter Descriptors but no luck.

I'd be really glad if you can assist me to the right direction.

Thank you in advance.
Dimitrina
Telerik team
 answered on 07 Nov 2014
4 answers
161 views
For simple things like adding two numeric columns I'm in good shape but I have two use cases that I can't seem to figure out how to express.
The data structure is an Account object at the root that has 1 or more Detail child objects.  Detail has a few different string properties.
What I want to be able to do is filter down to Account rows where it has at least one Detail object where its property is equal to a certain string.
In C# it would be like this:
var foo = db.Accounts.Where(a => a.Details.Any(b => b.HCPCS == "55555"));

Also,
I wanted to know if there way any way to cast strings to ints in the editor.
Something like
int.Parse(Field) > 50
Nick
Telerik team
 answered on 07 Nov 2014
3 answers
466 views
I am trying to change the style of the scroll bar on both the Pivot Grid and field list. At the moment when the mouse floats over the "Thumb" (that's the small part of the control you drag left or right or up and down), it turns a solid black which is not the behavior we want.
How can we change the back color of the "thumb" part of the scroll bar when the mouse flats over it.

Thanks
Kalin
Telerik team
 answered on 07 Nov 2014
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
PasswordBox
SplashScreen
Callout
Rating
Accessibility
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?