Telerik Forums
UI for WPF Forum
1 answer
237 views
Hello,

I've encountered a problem that looks like so strange and I don't know how to deal with it. I tried a lot of combinations but nothing worked.

I've the "main" class 'MainWindow.cs' which has :

Datas datas = new Datas();
ConfigTabCameras ctc = new ConfigTabCameras(datas);
this.DataContext = datas;

MainWindow.xaml : 1st row doesn't work, 2nd works
<custom:TabCameras />
<telerik:RadGridView ItemsSource="{Binding DatasTabCameras}"/>

Datas.cs :
private ObservableCollection<ViewTabCameras> datasTabCameras;
 
public ObservableCollection<ViewTabCameras> DatasTabCameras
{
    get
    {
        if (this.datasTabCameras == null)
        {
            this.datasTabCameras = new ObservableCollection<ViewTabCameras>();
        }
 
        return this.datasTabCameras;
    }
    set
    {
        this.EventPropertyChanged("DatasTabCameras");
    }  
}
 
public Datas()
{
 
}

And the inheritance of INotifyPropertyChanged etc...

ConfigTabCameras :
public class ConfigTabCameras : AbstractSql
    {
        public ConfigTabCameras(Datas datas)
        {
            this.configurationDatas = datas;
            ConfigurationTabCameras();
        }
 
        private void TabCamerasConfiguration()
        {
            connect.dbConnect();
 
            command.CommandText = "SELECT f1, f2, f3 " +
                  "FROM t1ORDER BY f1";
            command.CommandType = CommandType.Text;
            command.Connection = connect.getSqlConnection();
 
            dataReader = command.ExecuteReader();
 
            while (dataReader.Read())
            {
                ViewTabCameras vtc = new ViewTabCameras();
 
                vtc.Field1 = dataReader["f1"].ToString();
                vtc.Field2 = int.Parse(dataReader["f2"].ToString());
                vtc.Field3 = int.Parse(dataReader["f3"].ToString());
                 
                donneesConfiguration.DatasTabCameras.Add(vtc);
            }
             
            command.Dispose();
            dataAdapter.Dispose();
 
            connect.dbDisconnect();
        }
    }

ViewTabCameras.cs :
private string field1;
private int field2;
private int field3;
 
public string Field1
{
    get
    {
        return this.field1;
    }
    set
    {
        this.field1= value;
        this.EventPropertyChanged("Field1");
    }
}
 
// Same for Field2 and 3...


And finally my custom UserControl as a GridView TabCameras.cs :
private Donnees donnees;
 
public TabCameras()
{
    datas = new Datas();
    //this.DataContext = datas;
    InitializeComponent();
}

TabCameras.xaml :
<telerik:RadGridView ItemsSource="{Binding DatasTabCameras}">
        <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Field1}"
                                            Header="Field 1"
                                            UniqueName="Field1" />
                <telerik:GridViewComboBoxColumn Header="Field 2"
                                                ItemsSource="{Binding Field2}"
                                                UniqueName="Field2"
                                                DataMemberBinding="{Binding Field2}" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Field3}"
                                                Header="Field 3"
                                                UniqueName="Field3" />
        </telerik:RadGridView.Columns>
</telerik:RadGridView>


So the MainWindow is supposed to include my custom controls but they don't display anything. However, when I add a GridView control in my MainWindow with the same binding, it works perfectly. I tried to change the position of "dataContext" in many classes but nothing changed.

So, how can I have my custom controls in my MainWindow which display everything returned by my SQL query and saved in my Datas.cs please ?

I hope I was clear enough, I don't think I used the easier way...

Thanks !
Christophe
Top achievements
Rank 1
 answered on 04 Jun 2014
2 answers
254 views
Hello

I have a windows with 4 radListBox.

this 4 rad listbox are binded to 4 Observable collection of the same Object type.

so i have radlist box A, B, C and D

what i want is :

 allow drag and drop
-betwen A and B (any directtion)
-between C and D (any direction)

disable drag and drop for all other posssibilities
-between B and C
-between B and D
-between A and C
-between A and D

i had already achieve this with radList box containing different type of Object by testing the type, but here i can't do it because all the radListBox contains the same type of object.

Any suggestion?
Olivier Constance
Top achievements
Rank 1
 answered on 04 Jun 2014
1 answer
148 views
Hi Team,

This is really cool stuff, if any of you could throw some light then its is good.

I have custom RadPropertyGrid and  custom DataTemplate which has a usercontrol inside it, I am creating my own Propertydefinitions and using SelectTemplate of dataTemplateselector ,I am  providing the Template for editing for each Property Item.
Now the issue is : I want to pass the  property definition information /propertyspecification  to the usercontrol inside the Datatemplate, So that it behaves accordingly.
For Example:
If it finds the propertydefintion  with "IsSelected" as true then it should check the  my checkbox and set the background color of my button to Red.Please not this checkbox and Button are child elements of my user control.



Ivan Ivanov
Telerik team
 answered on 04 Jun 2014
5 answers
203 views
Hi Team,'

Could you please help me out, How Can I create a Custom Editor for rendering the Items in the RadPropertyGrid, I want a behaviour similiar to ITypeEditor of Codeplex propertyGrid.

1) I load the property Grid with the objects that are created on runtime.
2) I want to  create a button  adjacent to  those properties in the propertyGrid which are boolean only.

Please help me out.
Ivan Ivanov
Telerik team
 answered on 04 Jun 2014
3 answers
519 views
On a Cartesian chart (bar chart,) with certain values, the vertical axis is not starting at zero. Attached are two images. One shows the values formatted by default. The other is the values formatted as an integer. Note that the chart formatted as an integer is repeating values. The repetition is the ultimate problem, but I think it is the result of another problem (the vertical axis not starting at zero) or at least they are related in some manner.

Any suggestions? 
Petar Marchev
Telerik team
 answered on 04 Jun 2014
2 answers
172 views
In Diagram, I need select multi-object and show a mouse right  context menu, and then copy or paste them. is there any template or style can help to do this
rui
Top achievements
Rank 1
 answered on 04 Jun 2014
1 answer
137 views
The below is my XAML code:

<Window x:Class="CrmActivityTimer.SetRegardingEntities"
        Title="SetRegardingEntities" Height="337" Width="439"
        DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <Window.Resources>
        <Style x:Key="DraggableListBoxItem" TargetType="telerik:RadListBoxItem">
            <Setter Property="telerik:DragDropManager.AllowDrag" Value="True"/>
        </Style>
    </Window.Resources>
    <Grid>           
        <telerik:RadListBox ItemsSource="{Binding MetaData.RetrievedEntityMetaDatas}" HorizontalAlignment="Left" Height="190"
                            Margin="10,57,0,0" VerticalAlignment="Top" Width="182" ItemContainerStyle="{StaticResource DraggableListBoxItem}"
                            DisplayMemberPath="DisplayName.UserLocalizedLabel.Label" AllowDrop="True">
            <telerik:RadListBox.DragVisualProvider>
                <telerik:ListBoxDragVisualProvider />
            </telerik:RadListBox.DragVisualProvider>
            <telerik:RadListBox.DragDropBehavior>
                <telerik:ListBoxDragDropBehavior />
            </telerik:RadListBox.DragDropBehavior>
        </telerik:RadListBox>
        <telerik:RadListBox HorizontalAlignment="Left" Height="190" Margin="239,57,0,0" VerticalAlignment="Top" Width="182"
                            ItemsSource="{Binding MetaData.SavedEntityMetaDatas}" ItemContainerStyle="{StaticResource DraggableListBoxItem}"
                            DisplayMemberPath="DisplayName.UserLocalizedLabel.Label" AllowDrop="True">
            <telerik:RadListBox.DragVisualProvider>
                <telerik:ListBoxDragVisualProvider />
            </telerik:RadListBox.DragVisualProvider>
            <telerik:RadListBox.DragDropBehavior>
                <telerik:ListBoxDragDropBehavior />
            </telerik:RadListBox.DragDropBehavior>
        </telerik:RadListBox>  
    </Grid>
</Window>

I have followed the guide from the documentation at http://www.telerik.com/help/wpf/radlistbox-features-dragdrop.html, but it does not work. I can pickup an item from the left list, but I cannot drop it in the right list. It appears like on this image: http://i.stack.imgur.com/ADgPS.png. I also cannot reorder the ones on the left. it shows where I want to drop it, but it does not change anything. This is my code-behind:

public partial class SetRegardingEntities
    {
        public SetRegardingEntitiesMetaData MetaData { get; set; }
        public SetRegardingEntities()
        {
            MetaData = new SetRegardingEntitiesMetaData();
            InitializeComponent();
            IEnumerable<string> regardingTargets = CrmConnector.GetServiceAppointmentRegardingTargets();
            List<EntityMetadata> regardingmetadataList = new List<EntityMetadata>();
            foreach (string regardingTarget in regardingTargets)
            {
                regardingmetadataList.Add(CrmConnector.GetMetaDataForEntityName(regardingTarget));
            }
            MetaData.RetrievedEntityMetaDatas = regardingmetadataList.OrderBy(metadata => metadata.DisplayName.UserLocalizedLabel.Label).ToList();
        }
 
        private void btnSaveBetreft_onclick(object sender, RoutedEventArgs e)
        {
            List<string> regardingTargetsList = MetaData.SavedEntityMetaDatas.Select(savedEntityMetaData => savedEntityMetaData.LogicalName).ToList();
            SettingsSaver.SaveRegardingList(regardingTargetsList);
            ActivityTimerContainer activityTimerContainer = new ActivityTimerContainer();
            activityTimerContainer.Show();
            Close();
 
        }
    }
 
    public class SetRegardingEntitiesMetaData : INotifyPropertyChanged
    {
        private List<EntityMetadata> _retrievedEntityMetadatas;
        private List<EntityMetadata> _savedEntityMetadatas;
 
        public List<EntityMetadata> RetrievedEntityMetaDatas
        {
            get { return _retrievedEntityMetadatas; }
            set
            {
                if (_retrievedEntityMetadatas == value)
                {
                    return;
                }
                _retrievedEntityMetadatas = value;
                OnPropertyChanged();
            }
        }
 
        public List<EntityMetadata> SavedEntityMetaDatas
        {
            get { return _savedEntityMetadatas; }
            set
            {
                if (_savedEntityMetadatas == value)
                {
                    return;
                }
                _savedEntityMetadatas = value;
                OnPropertyChanged();
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
 
        private void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

The EntityMetaData object is from the Dynamics CRM 2011 SDK.
Kalin
Telerik team
 answered on 04 Jun 2014
1 answer
98 views
I have a TreeListView with a IsExpandedBinding to my view model (TwoWay).
Before I show the tree the first time, I expand a couple of nodes programmatically to show the tree initially in a state which is most useful for the customer. Due to UI virtualization I noticed that some of the nodes which I expanded programmatically get collapsed again which causes a not desired initial view of my tree. If I switch off UI virtualization, everything works as expected, BUT this is not acceptable since I will have up to 100.000 rows in my tree.
Any thoughts on how to solve this problem?

Thanks,
Markus
Yoan
Telerik team
 answered on 04 Jun 2014
1 answer
88 views
In my RadGridView I define common style for all items via RowStyle. Unfortunately, it works properly only for 1,3,5.... - ItemsSource's items with odd numbers.
What am I missing?
Aleksandr
Top achievements
Rank 1
 answered on 04 Jun 2014
1 answer
128 views
Hi,

we have an encoding problem in a autocompletenbox. As you can see on the attached file all "ä", "ü", "ö", "ß", are something like
a "?". We bind a txt-file to the autocompletebox.
using (StreamReader reader = new StreamReader(file, System.Text.Encoding.UTF8))
{
    string line;
    Int32 i = 0;
    while ((line = reader.ReadLine()) != null)
    {
        i++;
        string[] tmp = line.Split(';');
        vartab.Add(new Vartab(tmp[1], tmp[0], i));
    }
}

How can we solve this problem?

Thanks a lot
Best Regrads from Austria
Rene
Rosen Vladimirov
Telerik team
 answered on 03 Jun 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?