Telerik Forums
UI for WPF Forum
1 answer
96 views
Hi there,

I have a connection to a MySQL-database and created my classes via EntityFrameWork.
I bound my GrdiView to one of the tables.

If I add a new object to the table, my GridView is not updated, until I reorder the items.
How can I update my GridView without using codebehind, because I am using MVVM for this project.

Best Regards
Manfred
Pavel Pavlov
Telerik team
 answered on 11 Apr 2013
4 answers
402 views
Hi, I'm coding UI tests and the most common task is to navigate to controls situated in different tabs using automation. The problem is I can't get the content of tabs except the tab selected by default. That is, I change between different tab pages and only the first one's automation tree is visible. The code is something like that below. The default WPF tab control works fine: I can get the content of currently selected tab. So how can this problem be solved? Thanks in advance.

[TestMethod]
public void TestMethod()
{
    // find app window
    var cond = new PropertyCondition(AutomationElement.NameProperty, "MainWindow");
    AutomationElement foundWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children, cond);
 
    // find tab control
    cond = new PropertyCondition(AutomationElement.ControlTypeProperty, System.Windows.Automation.ControlType.Tab);
    AutomationElement foundTab = foundWindow.FindFirst(TreeScope.Subtree, cond);
 
    var tabCtl = (WpfTabList)UITestControlFactory.FromNativeElement(foundTab, "UIA");
 
    foreach (var tab in tabCtl.Tabs)
    {
        var elements = "";
        Mouse.Click(tab);
 
        // do something to controls,
        // for example collect their names
        foreach (var el in Walk(tab.NativeElement as AutomationElement))
        {
            elements += string.Format("Name: '{0}', Type: '{1}'\n", el.Current.Name, el.Current.ControlType.ProgrammaticName);
        }
        MessageBox.Show(elements);
    }
}
 
// Recursively walk an automation tree
private List<AutomationElement> Walk(AutomationElement current)
{
    var res = new List<AutomationElement>();
    if (current != null)
    {
        res.Add(current);
        res.AddRange(Walk(TreeWalker.RawViewWalker.GetFirstChild(current)));
        res.AddRange(Walk(TreeWalker.RawViewWalker.GetNextSibling(current)));
    }
    return res;
}
Tina Stancheva
Telerik team
 answered on 11 Apr 2013
1 answer
324 views
When hovering property grid items, the background changes to whatever the theme uses as background. I believe this is caused by the MouseOver stuff in PropertyGridFieldTemplate:

<Rectangle x:Name="Background_Over"  Grid.ColumnSpan="2"  Fill="{telerik:Windows8TouchResource ResourceKey=MainForegroundBrush}" Opacity="0.05" HorizontalAlignment="Stretch" Visibility="{Binding IsMouseOver, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}" VerticalAlignment="Stretch"/>

Is it possible to change this style for my property grid? Our application allows for switching between themes, so it makes sense to base the styles on the current style of the desired type (i.e. BasedOn). Not sure if this is possible if we need to change the entire style.

So, two questions:
1) How do we change the hovering color? (I.e. on mouse over, we want to use the background color of the property grid. Maybe darkening it a bit.)
2) How do we remove the gray area to the left?
Kristoffer
Top achievements
Rank 1
 answered on 11 Apr 2013
3 answers
124 views
I have trouble with some of my map elements, for example MapLine.

When I use this syntax the MapLine is displayed in red and shows a tooltip when mouse is over.

<tel:MapLine
  StrokeThickness="5"
  Stroke="Red"
  Point1="{Binding MyViewModel.Point1}"
  Point2="{Binding MyViewModel.Point2}"
  ToolTip="{Binding MyViewModel.ItemName}" />


When I use this syntax the MapLine is not displayed and there is no tooltip.

<tel:MapLine
  StrokeThickness="5"
  Point1="{Binding MyViewModel.Point1}"
  Point2="{Binding MyViewModel.Point2}">
  <tel:MapLine.Stroke>
    <SolidColorBrush Color="Red" />
  </tel:MapLine.Stroke>
  <tel:MapLine.ToolTip>
    <TextBlock Text="{Binding MyViewModel.ItemName}" />
  </tel:MapLine.ToolTip>
</tel:MapLine>
Andrey
Telerik team
 answered on 11 Apr 2013
1 answer
137 views
When I use binding to set the Location of a MapShape I always get an Error. What am I doing wrong?

<tel:MapRectangle Location="{Binding Location}" />

Exception:
A 'Binding' cannot be set on the 'Location' property of type 'MapRectangle'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
Andrey
Telerik team
 answered on 11 Apr 2013
1 answer
208 views
Hi

I have one question. How can I highlight an item from ViewModel? I have simple MVVM scenario:

public class FooViewModel : ViewModelBase
    {
        private ObservableCollection<Foo> _fooCollection;
        private Foo _selectedFoo;
        private ICommand _addCommand;
 
        public ObservableCollection<Foo> FooCollection
        {
            get { return _fooCollection; }
            set
            {
                _fooCollection = value;
                OnPropertyChanged("FooCollection");
            }
        }
 
        public Foo SelectedFoo
        {
            get { return _selectedFoo; }
            set
            {
                _selectedFoo = value;
                OnPropertyChanged("SelectedFoo");
            }
        }
 
        public ICommand AddCommand
        {
            get { return _addCommand ?? (_addCommand = new RelayCommand(i=>this.AddCommandMethod())); }
        }
 
        private void AddCommandMethod()
        {
            //Add item to collection
            //Add item to SelectedFoo
        }

In View I bind ItemSource to FooCollection, I am binding the SelectedItem of the RadListBox to SelectedFoo from VM and I have two TextBlocks to display the SelectedFoo. I have one button to Add a new Item to the Collection and setting the SelectedFoo to this new Item from Collection. Everything is fine, the two textblocks shows correct data, but the RadListBox is not highlighting the new Item Added to the collection. The collection rebinds fine because I can see the added item in list, but it is not highlighted. 

Am I doing something wrong?? I tried to set the SelectedValue, SelectedValuePath, SelectedItem. I have google it a lot but no luck.

Thanks Vitalij
Vitalij
Top achievements
Rank 1
 answered on 11 Apr 2013
2 answers
162 views
I am using 2 listboxes with drag and drop enabled, 1 being the "source" and one being the "destination".
I need to manipulate the items in the "destination" RadListBox when a user drops an item from the "source" listbox; after a certain validation.

I wired the "PreviewDrop" event; but fail to see how I can get the datacontext of the element that is being dropped by the user.
(I worked through the properties of the DragEventArgs parameter; but couldn't find the datacontext of the item that is being dropped)

Does anyone know how to determine which item the user is dropping on my "destination" RadListBox ?

Luc Cappaert
Top achievements
Rank 2
 answered on 11 Apr 2013
1 answer
127 views
I'm trying to use LabelFormat in DateTimeCategoricalAxis but an exception occurs when i use H format string. =>it's work with HH for example
I want to use h (just hour with one digit for 1,2,3...), ddd, d (just day for 1,2,3...) and MMM in final testing

Xaml View :
<telerik:RadCartesianChart>
 
           <telerik:RadCartesianChart.HorizontalAxis>
               <telerik:DateTimeCategoricalAxis LabelFitMode="None"
                                                LabelFormat="H"
                                                DateTimeComponent="Hour" />
           </telerik:RadCartesianChart.HorizontalAxis>
 
           <telerik:RadCartesianChart.VerticalAxis>
               <telerik:LinearAxis />
           </telerik:RadCartesianChart.VerticalAxis>
 
           <telerik:LineSeries ItemsSource="{Binding}"
                               CategoryBinding="XValue"
                               ValueBinding="YValue"/>
 
       </telerik:RadCartesianChart>

Data object :
public class ChartData
   {
       public DateTime XValue
       {
           get;
           set;
       }
 
       public Double YValue
       {
           get;
           set;
       }
   }

Code for initialize data :
List<ChartData> datas = new List<ChartData>();
 
           for (int i = 0; i < 23; i++)
           {
               datas.Add(new ChartData
                   {
                       XValue = DateTime.Today.AddHours(i),
                       YValue = i
                   });
           }
 
           DataContext = datas;






LOUGE
Top achievements
Rank 1
 answered on 11 Apr 2013
5 answers
109 views
Hi again. I have the following problem: If in the page's Loaded event I set the focus on one of my RadComboBoxes, even though it becomes the active control and I can browse through the elemnts with the Up and Down keys, it doesn't change the way it looks, so there's no way for the user to know that the control is active.

Now if I, at runtime, use the Tab key to select it, then I get the different style. Is there anything besides (or instead of) the call to the Focus method on the page's Loaded event I should do to get the control to appear different when it's focused?

PS: I'm not setting any specific style to the control, I'm just using whatever default behaviour it's got (usually, an orange border around it shows that it's the active control).

Thanks a lot. You continuous help is very appreciated.
Yana
Telerik team
 answered on 11 Apr 2013
6 answers
186 views
Hi!
I have a simple task to be done! I have to display a chart using <RadChart> (like one in attachment). It is a simple horizontal bar (I guess with two series STOPPED, ACTIVE). 

The chart should display time o X axis and tho series of graph (red for STOPPED, green for ACTIVE). Assumig I can use the DLYChartPoint structure. Or not?!

I have problems displaying the data, so a little help would be appreciate.

Thanks in advice!

My code:
C#:
public class DLYChartPoint : LPDEntityStatus
	{
		#region Private
		string label;
		double value;
	        long uniqueId;
 
		#endregion

	// other class structures
}

------------------------------------------------------------------------------------------
public ObservableCollection<DLYChartPoint> TimeLineChart


WPF:
<telerik:RadChart x:Name="timeLineChart" ItemsSource="{Binding TimeLineChart, Mode=TwoWay}">
    <telerik:RadChart.DefaultView>
        <telerik:ChartDefaultView>
            <telerik:ChartDefaultView.ChartLegend>
                <telerik:ChartLegend Visibility="Collapsed" />
            </telerik:ChartDefaultView.ChartLegend>
        </telerik:ChartDefaultView>
    </telerik:RadChart.DefaultView>
    <telerik:RadChart.SeriesMappings>
		<telerik:SeriesMapping>
			<telerik:SeriesMapping.SeriesDefinition>
                <telerik:HorizontalStackedBarSeriesDefinition ></telerik:HorizontalStackedBarSeriesDefinition>
			</telerik:SeriesMapping.SeriesDefinition>
            <telerik:SeriesMapping.ItemMappings>
                <telerik:ItemMapping DataPointMember="Label" FieldName="Value"></telerik:ItemMapping>
                <telerik:ItemMapping DataPointMember="YValue" FieldName="Value"></telerik:ItemMapping>
                <telerik:ItemMapping DataPointMember="XCategory" FieldName="Label"/>
            </telerik:SeriesMapping.ItemMappings>
		</telerik:SeriesMapping>
	</telerik:RadChart.SeriesMappings>
</telerik:RadChart>
Luka
Top achievements
Rank 1
 answered on 11 Apr 2013
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?