Telerik Forums
UI for WPF Forum
0 answers
113 views
Edit:
Here is the solution:

<telerik:GridViewComboBoxColumn Header="Location"
                                    DataMemberBinding="{Binding LocationId}"
                                    UniqueName="LocationId"
                                    ItemsSourceBinding="{Binding Path=Locations,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
                                    SelectedValueMemberPath="Id"
                                    DisplayMemberPath="Name" />


I am evaluating the GridView and have ran into an issue binding the domain data which represents each row  to the ComboBox in the GridView using MVVM.  The GridView  is populated with Employees.  Each employees (Employee class) has a list of locations (Locations property on the Employee class) and a SelectedLocationId.  These locations will fill the combobox in a column in the GridView.  So for example, I have two employees, each bound to the Grid:

public class MyViewModel{
 
    public BindingList<Employee> Employees { //The grid binds to this list}
}
 
public class Employee{
    public string Name{...}
    public int SelectedLocationId {...}
    public BindingList<Location> Locations {...} //Binds to combobox in grid.
//Location class has Name and Id property
}


The data:
Joe
Locations: US, Canada
SelectedLocation: Canada
Bob
Locations: US, Mexico
SelectedLocation: Mexico

One of the columns in the grid should be "Location" with a combobox column which has the respective data for each employee.  I tried this in the GridView:

     
<telerik:GridViewComboBoxColumn Header="Location"
                              ItemsSource="{Binding Path=Locations, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:GridViewRow}}"
                              DisplayMemberPath="Name"
                              FocusVisualStyle="{x:Null}"
                      SelectedValueMemberPath="Id">

However, I see in the output, that the Combobox is trying to bind to the ViewModel instead of the domain entity Employee.  How can I bind a combobox in the grid to a list on the domain entity in each row?

Thanks for your help!
+++AAA+__WOULD BUY AGAIN ++++
Top achievements
Rank 1
 asked on 06 Aug 2012
2 answers
134 views
I'm having problems with the header on my RadDocument.  I've attached an image of what is occurring.  The header has two paragraphs, the first showing the page fields and the second spans mimicking column headers for the table in the document.  The first time the document is displayed, the content for the two paragraphs is switched.  After paging, it is corrected.  The switch will also come back if I maximize the window.  Below is the code that creates the header document....
private RadDocument CreateHeaderDocument(List<GridViewBoundColumnBase> columns)
{
    RadDocument document = new RadDocument();
    Section section = new Section();
    Paragraph paragraph = new Paragraph();
    paragraph.FontSize = fontSize;
    PageField pageField = new PageField()
    {
        DisplayMode = FieldDisplayMode.Result
    };
    FieldRangeStart pageFieldStart = new FieldRangeStart();
    pageFieldStart.Field = pageField;
    FieldRangeEnd pageFieldEnd = new FieldRangeEnd();
    pageFieldEnd.Start = pageFieldStart;
    paragraph.Inlines.Add(pageFieldStart);
    paragraph.Inlines.Add(pageFieldEnd);
    FieldRangeStart numPagesFieldStart = new FieldRangeStart();
    numPagesFieldStart.Field = new NumPagesField()
    {
        DisplayMode = FieldDisplayMode.Result
    };
    FieldRangeEnd numPagesFieldEnd = new FieldRangeEnd();
    numPagesFieldEnd.Start = numPagesFieldStart;
    var ofSpan = new Span(" of ");
    ofSpan.FontFamily = fontFamily;
    ofSpan.FontSize = fontSize;
    ofSpan.FontWeight = FontWeights.Bold;
    ofSpan.ForeColor = Color.FromArgb(255, 0, 0, 0);
    paragraph.Inlines.Add(ofSpan);
    paragraph.Inlines.Add(numPagesFieldStart);
    paragraph.Inlines.Add(numPagesFieldEnd);
    section.Blocks.Add(paragraph);
    var hdrPara = new Telerik.Windows.Documents.Model.Paragraph();
    hdrPara.Background = _headerBackground;
    var spaceWidth = GetScreenSize("i", fontFamily, fontSize, FontWeights.Bold, FontStyles.Normal, FontStretches.Normal).Width;
    foreach (GridViewBoundColumnBase col in columns)
    {
        String s = String.Empty;
        if (col.Header != null)
        {
            s = col.Header as String;
        }
        var span = new Telerik.Windows.Documents.Model.Span(s);
        span.FontFamily = fontFamily;
        span.FontSize = fontSize;
        span.FontWeight = FontWeights.Bold;
        span.ForeColor = Color.FromArgb(255, 0, 0, 0);
        var hdrWidth = GetScreenSize(span.Text, span.FontFamily, span.FontSize, span.FontWeight, FontStyles.Normal, FontStretches.Normal).Width;
        var spaces = (col.ActualWidth - hdrWidth) / spaceWidth;
        for (int i = 0; i < spaces; i++)
        {
            span.Text += " ";
        }
        hdrPara.Inlines.Add(span);
    }
    section.Blocks.Add(hdrPara);
    document.Sections.Add(section);
    return document;
}

Please advise, as this is definitely a show stopper,
Thanks,
Steve



P.S. I also am curious as to why all the text in the header is gray; even when explictly setting the color to black. 






Iva Toteva
Telerik team
 answered on 06 Aug 2012
4 answers
233 views
Is there are built-in way to have a 'close all' option appear in the RadTabControl's drop-down menu? We have a close button on each tab, but it would be nice to also have an option in the drop down to close everything out.

Can this also be easily done in a context menu?
Alex Fidanov
Telerik team
 answered on 06 Aug 2012
5 answers
136 views
After updating to the 2012.2 version I have problems with the RadRichTextBox.
When running my application it fails:

Exception: Object reference not set to an instance of an object.
Telerik.Windows.Documents.UI.DocumentWebLayoutPresenter
ClearPresenterUI

Source: Telerik.Windows.Documents
Target: Void ClearPresenterUI()
Stacktrace:    at Telerik.Windows.Documents.UI.DocumentWebLayoutPresenter.ClearPresenterUI()
   at Telerik.Windows.Documents.UI.DocumentWebLayoutPresenter.DoOnDocumentChanging()
   at Telerik.Windows.Controls.RadRichTextBox.set_Document(RadDocument value)
   at Telerik.Windows.Documents.FormatProviders.DataProviderBase.UpdateDocument()
   at Telerik.Windows.Documents.FormatProviders.DataProviderBase.StringPropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
....

Iva Toteva
Telerik team
 answered on 06 Aug 2012
3 answers
516 views
Hello. I'm see differences in formatting using a VirtualizingWrapPanel vs using a standard WrapPanel.

Here is the xaml:

<Window x:Class="GalleryView3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
        Title="MainWindow" Height="350" Width="525" MinWidth="350">
    <Grid>
        <Border BorderThickness="3" MinWidth="100" MinHeight="100">
        <ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled" Name="TabGalleryListView" ItemsSource="{Binding Source}" SelectionChanged="SelectionChanged">
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                        <telerik:VirtualizingWrapPanel IsItemsHost="True" Orientation="Horizontal" />
                        <!--<WrapPanel IsItemsHost="True" Orientation="Horizontal" />-->
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <StackPanel Margin="10,10,10,10" Orientation="Vertical">
                        <Border BorderThickness="3" BorderBrush="Black">
                            <Image Width="128" Height="128" Source="{Binding ImageSource}" Stretch="Uniform" />
                        </Border>
                        <StackPanel Orientation="Horizontal" Margin="0,10,0,0" >
                            <CheckBox Margin="0,0,5,0" VerticalAlignment="Center"/>
                            <TextBlock TextWrapping="Wrap" VerticalAlignment="Center" Text="{Binding DisplayText}" Foreground="Red"/>
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        </Border>
    </Grid>
</Window>

You'll see where I've been commenting in/out the standard WrapPanel & the VirtualizingWrapPanel.

When I run with the WrapPanel enabled, and VWP commented out, I get the desired effect, a nice bunch of the same graphic with checkbox & text following. (first attached illustration)

When I run with the VWP enabled, and WrapPanel commented out, the image is not properly resized and the checkbox & text are clipped. (second attached illustration).

I'm thinking that they should both work the same! Hopefully you can tell me where I am going wrong.
My Telerik.Windows.Controls.dll version is 2012.2.607.40

Thanks!
Mark

mark
Top achievements
Rank 1
 answered on 06 Aug 2012
3 answers
114 views

Hi,

We had a RadGrid on a form and we are changing cell background of cells manually depending on values in the cells. ANd it works fine but when we scroll down and then back to up then applied colors are meshed up and applied incorrectly
We are using 2011.2.920.40 version of WPF controls.

Thanks

Maya
Telerik team
 answered on 06 Aug 2012
0 answers
82 views
Hi every body
 

I'm trying to use RadPropertyGrid in my wpf application. and I can use it but I can't make a property have a brows button like visual studio property pane. Hove can I make it?
Ahad
Top achievements
Rank 1
 asked on 06 Aug 2012
0 answers
440 views
I'm working on a radgridview and I want the user to be able to have an option to show or hide the columns of the grid withing the application. Is there any property that I can set to true that would do this? If not,  Would the best way to implement this be a context menu? I have no room for a checkbox in the application or anything like that. Any code or suggestions would help. Here is the code I currently have to build the grid in the xaml. I am working in C# WPF.
<telerik:RadGridView Name="ExceptionsListBox" 
                                     IsReadOnly="True"
                                     ReorderColumnsMode="Interactive"
                                     UseLayoutRounding="False"
                                     EnableRowVirtualization="True"
                                     AutoGenerateColumns="False" 
                                     RowIndicatorVisibility="Collapsed"
                                     Background="#FF202020"
                                     RowHeight="20"
                                     GroupPanelBackground="#FF202020"
                                     GroupPanelForeground="white" 
                                     telerik:StyleManager.Theme="Expression_Dark" Grouped="ExceptionsListBox_Grouped">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Key}"
                                                    Header="Type"/>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding TypeText}"
                                                    Header="Error" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Message}"
                                                    Header="Error Message" />
                    </telerik:RadGridView.Columns>
                    <telerik:RadGridView.Resources>
                        <Style TargetType="telerik:GridViewHeaderRow">
                            <Setter Property="MinHeight" Value="15" />
                        </Style>
                        <Style TargetType="telerik:GridViewGroupPanel">
                            <Setter Property="MinHeight" Value="10" />
                            <Setter Property="Height" Value="10" />
                        </Style>
                          
                    </telerik:RadGridView.Resources>
                </telerik:RadGridView>
 
Tyler
Top achievements
Rank 1
 asked on 06 Aug 2012
1 answer
319 views

Hi Team Telerik,

My Code to list spell Check Suggestions in the Context Menu upon right clicking on the wrongly added text in the RichTextBox is n't working any more.
Actually what I did is :-

1. Enabled Richtextbox spell check property.
2) Enabled Richtextbox ContextMenu Enabled Property
3) Read * .tdf file as stream and load dictionary directly from the tdf stream

                               Private Sub LoadDictionary(ByVal tdfFileStream As Stream)

                                              Dim dictionary As New RadDictionary()

                                              dictionary.Load(tdfFileStream)

CType(Me.radRichTextBox.SpellChecker, DocumentSpellChecker).AddDictionary(dictionary, CultureInfo.CurrentCulture)

                               End Sub

RadRichtextBox property IsContextMenuEnabled is set to True ,but it is not working.

Is there any property to show
spell Check Suggestions apart from customizing the Context menu ?
Will it show the spell Check Suggestions in the Context Menu by adding the Reference to
Telerik.Windows.Documents.Proofing.Dictionaries.En-US.dll assembly by default ?

Does anyone have any suggestions why this may be?

Thank you for your time,

Lakshmi

Iva Toteva
Telerik team
 answered on 06 Aug 2012
11 answers
287 views
I am using WPF MVVM and having some trouble dragging an image from my application to the desktop. Any time I drag outside of the application the DragStatus becomes DragStatus.Cancel.

What am I doing wrong? I can post the relative code if this is not a simple thing.
Nick
Telerik team
 answered on 06 Aug 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?