Telerik Forums
UI for WPF Forum
7 answers
1.4K+ views
I've made a small example which illustrates my problem:

MainWindow.xaml:
<Window x:Class="TestListView.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
        Title="MainWindow" Height="350" Width="525"
        DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <Window.Resources>
        <ResourceDictionary>
            <Style TargetType="ScrollViewer">
                <Setter Property="telerik:StyleManager.Theme"  Value="Windows7" />
                <Setter Property="VerticalScrollBarVisibility"  Value="Auto" />
                <Setter Property="HorizontalScrollBarVisibility"  Value="Auto" />
            </Style>
        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <ListView Grid.Row="0" Grid.Column="0" x:Name="_lwReminders" Margin="1" Background="WhiteSmoke" ItemsSource="{Binding TheList}"
                      HorizontalAlignment="Stretch" SelectionMode="Single"                    
                      ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                        ScrollViewer.VerticalScrollBarVisibility="Auto"
                      ScrollViewer.CanContentScroll="False"
                      HorizontalContentAlignment="Stretch"
                      VerticalContentAlignment="Stretch"
                      VirtualizingStackPanel.IsVirtualizing="True"
                       VirtualizingStackPanel.VirtualizationMode="Recycling">
            <ListView.ItemContainerStyle>
                <Style TargetType="{x:Type ListViewItem}">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    <Setter Property="Focusable" Value="false"/>
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <TextBox Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch"
                            VerticalAlignment="Center" TextWrapping="Wrap" TextAlignment="Left"
                            Text="{Binding Description}" Margin="5" AcceptsReturn="True" AcceptsTab="True"  />
                            <!--Style="{StaticResource TextBoxInputStyle}" />-->


                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</Window>

MainWindow.xaml.cs:
public partial class MainWindow : Window
    {
        public class Animal
        {
            public string Name { get; set; }
            public string Description { get; set; }
        }
        public MainWindow()
        {
            InitializeComponent();
            TheList.Add(new Animal{Description = "Elephants are large mammals of the family Elephantidae and the order Proboscidea. Traditionally, two species are recognised, the African elephant (Loxodonta africana) and the Asian elephant (Elephas maximus), although some evidence suggests that African bush elephants and African forest elephants are separate species (L. africana and L. cyclotis respectively). Elephants are scattered throughout sub-Saharan Africa, and South and Southeast Asia. They are the only surviving proboscideans; extinct species include mammoths and mastodons. The largest living terrestrial animals, male African elephants can reach a height of 4 m (13 ft) and weigh 7,000 kg (15,000 lb). These animals have several distinctive features, including a long proboscis or trunk used for many purposes, particularly for grasping objects. Their incisors grow into tusks, which serve as tools for moving objects and digging and as weapons for fighting. The elephant's large ear flaps help to control the temperature of its body. African elephants have larger ears and concave backs while Asian elephants have smaller ears and convex or level backs."});
            TheList.Add(new Animal{Description = "The giraffe (Giraffa camelopardalis) is an African even-toed ungulate mammal, the tallest living terrestrial animal and the largest ruminant. Its species name refers to its camel-like appearance and the patches of color on its fur. Its chief distinguishing characteristics are its extremely long neck and legs, its horn-like ossicones and its distinctive coat patterns. It stands 5–6 m (16–20 ft) tall and has an average weight of 1,600 kg (3,500 lb) for males and 830 kg (1,800 lb) for females. It is classified under the family Giraffidae, along with its closest extant relative, the okapi. The nine subspecies are distinguished by their coat patterns."});
            TheList.Add(new Animal { Description = "The lion (Panthera leo) is one of the four big cats in the genus Panthera and a member of the family Felidae. With some males exceeding 250 kg (550 lb) in weight,[4] it is the second-largest living cat after the tiger. Wild lions currently exist in sub-Saharan Africa and in Asia (where an endangered remnant population resides in Gir Forest National Park in India) while other types of lions have disappeared from North Africa and Southwest Asia in historic times. Until the late Pleistocene, about 10,000 years ago, the lion was the most widespread large land mammal after humans. They were found in most of Africa, across Eurasia from western Europe to India, and in the Americas from the Yukon to Peru.[5] The lion is a vulnerable species, having seen a major population decline of 30–50% over the past two decades[date missing] in its African range.[2] Lion populations are untenable outside designated reserves and national parks. Although the cause of the decline is not fully understood, habitat loss and conflicts with humans are currently the greatest causes of concern. Within Africa, the West African lion population is particularly endangered." });
        }


        private readonly List<Animal> _theList = new List<Animal>();
        public List<Animal> TheList
        {
            get { return _theList; }
        }
    }


The solution attached contains a style on Scrollviewer, which sets the theme, verticalscrollbarvisibility and horizontalscrollbarvisibility.

If I remove the 3 setters from the style, then the example does what I want it to (see jpg-file example A, textbox uses wrap), but when the 3 setters are in the style it kind of destroys the way it is supposed to work (see jpg-file example B, textbox does not use wrap).

How do I get my small application to use the 3 setters while behaving like in example A ?

Thanks
Inger Marie
Top achievements
Rank 1
 answered on 26 Mar 2013
11 answers
673 views
I'm using RadPropertyGrid to display multiple groups of properties & need to know how to: Control the Display Order of the Groups.

I define the PropertyDefinitions in the order in which I want them in in XAML, but the groups don't display in either alphabetical or
the order I define them.

How can I fix this in XAML or code-behind?

Alan
Maya
Telerik team
 answered on 26 Mar 2013
2 answers
152 views
Hi may I ask which version of the telerik support Editor Attribute
such as

[Editor(typeof(CustomActionEditor), typeof(UITypeEditor))]
public string FirstName {get;set;}

Also I found out the TypeConverter is not supported in WPF propertygrid as well
    [Description("The phone number of the employee in his office.")]
    [Display(Name = "Phone Number", Order = 3, GroupName = "Personal Information")]
    [TypeConverter(typeof(TestTypeConvertor))]
    public string PhoneNum
    {
        get
        {
            return phoneNum;
        }
        set
        {
            if (this.phoneNum != value)
            {
                this.phoneNum = value;
            }
        }
    }
 
public class TestTypeConvertor:TypeConverter
{
    public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
    {
        var i = 0;
        return base.CanConvertTo(context, destinationType);
    }
    public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
    {
        var i = 1;
        return base.CanConvertFrom(context, sourceType);
    }
}


Thanks
George
George
Top achievements
Rank 1
 answered on 25 Mar 2013
1 answer
149 views
I cannot seem to find a method of placing a border around the plotted bar; i.e. each bar on the graph should get a border around it and not entire graph or plot area itself. Does this require custom display handling? I've tried the basic style override and poking in with Snoop, but I cannot locate a place where that border can be changed and the border actually shows.

If manual drawing the bar is required, is there a sample of that hook routine?

Thanks in advance for any insight.
Matt
Top achievements
Rank 2
 answered on 25 Mar 2013
0 answers
124 views
I've read over the documentation for the GridView and it covers copying to the clipboard and it sort of covers pasting  back.

My requirements are as follows:
The user can only select the entire row
The user can copy the row's contents to the clipboard
The user can cut the row's contents to the clipboard - this should cause the selected row to be deleted both in the grid and in the collection the grid is bound to.
The user can paste a new row from the clipboard.  This should cause a new row to be interested in the grid before the currently selected row (push the selected row down).

I have the copy to the clipboard working.  I'm not clear on how to catch the CTRL+X for cut, but I think the implementation should be pretty easy. 

Pasting is less clear.  Can I just replace the e.Value with a new instance of my entity w/o blowing away the object that was there?  Or do I need to do the work behind the scene -
1. create my new instance
2. find the selected instance in my collection and insert it there
3. change the selected instance to my new instance

Any suggestions or directions would be greatly appreciated.
Jake
Top achievements
Rank 1
 asked on 25 Mar 2013
1 answer
238 views
UPDATE: It actually seems that MainWindow binding to itself was causing the issue.. not 100% sure yet but I think you can ignore this ;D
Update2: Yep you can defo ignore this. Or delete the tread if you want ;)

Telerik is causing what seems to be a stack overflow exception in VS2012's designer process. After each compile, the program will hang until I terminate said process after which I have to click 'reload designer' and then it'll work again until the next recompile (or control addition, it seems.)

 Here's a project to reproduce the issue:
*links removed*

1. Open MainWindow.xaml
2. Compile
3. Change any text, like in the comment I put at the top
4. Recompile

And then it'll hang.. you can kill the xdesproc process, click reload UI, and it'll happen all over again. I tested this on various systems and it always happens. I *think* the problem is limited to the RadDock but I'm not sure of that.
Chavdar Dimitrov
Telerik team
 answered on 25 Mar 2013
3 answers
227 views
Hello,

I'm using a radgridview and need to display a column that supports multiple values. For example I have a field "Supported Languages" that can take multiple values such as "English, Arabic, French" .. What type of datacolumn should I be  using to display this data? I tried using the ComboBoxColumn, however it requires separate bindings for the ItemsSource and DisplayMemberPath. I'm trying to avoid using concatenated strings. Please advise.

Thanks.
Dimitrina
Telerik team
 answered on 25 Mar 2013
3 answers
234 views
I've got a RadGridView in a WPF 4.5 app I'm working on, which involves grouping. I had a hard time trying to get the data to work initially in the designer (it's coming from a WCF service), but want to be able to do styling of the GridView with sample data. I found an article on MSDN called Walkthrough: Using Sample Data in the WPF Designer, which is helpful, but not entirely complete for the RadGridView. For example, that article discussed opening the ItemsSource property of the out-of-the-box DataGrid control. I tried doing that with the RadGridView, but it didn't work. I'm guessing I'm doing something wrong, but am not sure what, so I would like some direction, please.
Yoan
Telerik team
 answered on 25 Mar 2013
2 answers
138 views
I have a radgrid and when i turn the dataload mode to asynchronous it looses the group descriptors and sort descriptors. Also when binding is async it does the same thing. Can someone suggest some workaround or is this a normal behavior?
Nivid
Top achievements
Rank 2
 answered on 25 Mar 2013
1 answer
286 views
Hi,
I'm having an issue that's been going around for a few days, and I haven't found a solution yet. Here's the problem. I have data that I need to bind to the RadGridView, but the data changes all the time, and I have to let the gridview be flexible to handle whatever I throw at it. The first suggestion would be to create a DataTable with custom columns...well that worked at first, but we need to add ComboBoxColumns to the grid with pre-selected values from lists, so a DataTable is out.

I ended up binding the the GridView columns and Itemssource to Model objects, and the Itemssource was a List of "dynamic" objects, with custom properties. That worked, and allowed me to bind the gridView to custom data and have pre-selected ComboBox columns working. HOWEVER, it's just sooo slow. Have yall encountered this question before and did you find a way to speed things up, or is there a better way to bind the data?

I tried binding to a Dictionary<string, object>, but of course that won't work, because the columns are looking for object properties, not a property of type Dictionary with fields, so then the binding never happens. I also looked at your examples of binding with multiple data sources, but didn't see quite the exact same scenario.

Thanks,
Ryan
Nedyalko Nikolov
Telerik team
 answered on 25 Mar 2013
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
PersistenceFramework
DataPager
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
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?