Telerik Forums
UI for WPF Forum
8 answers
233 views
I am really confused with how to DataBind. I have 2 nearly identical projects, one using LINQ, the other OpenAccess, using only the Categories table from the Northwind database. Basically, a grid (of that table), and 2 textboxes for editing / 2-way binding.

Here is the code for Window1.xaml (LINQ Project):
<Window x:Class="NWLinq.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:NWLinq" 
    Title="Northwind LINQ" Height="400" Width="575" xmlns:my="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"> 
    <Window.Resources> 
        <ObjectDataProvider x:Key="objectDataProvider" ObjectType="{x:Type local:TestViewModel}"  /> 
    </Window.Resources> 
 
    <Grid DataContext="{Binding Source={StaticResource objectDataProvider}}"> 
        <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="200*" /> 
            <ColumnDefinition Width="300*" /> 
        </Grid.ColumnDefinitions> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="60*" /> 
            <RowDefinition Height="60*" /> 
            <RowDefinition Height="240*" /> 
        </Grid.RowDefinitions> 
        <my:RadGridView  
            Grid.Row="2"  
            Name="radGridView1"  
            Grid.ColumnSpan="2"  
            ColumnsWidthMode="Fill" 
            IsReadOnly="False"  
            SelectedItem="{Binding SelectedItem}" 
            ItemsSource="{Binding CategoryList}"              
        > 
        </my:RadGridView> 
        <TextBlock Margin="91,16,41,10" Name="textBlock1" Text="Name" HorizontalAlignment="Right" VerticalAlignment="Center" /> 
        <TextBlock Margin="91,14,41,8" Name="textBlock2" Grid.Row="1" Text="Description" HorizontalAlignment="Right" VerticalAlignment="Center" /> 
        <TextBox Grid.Column="1" Margin="58,15,64,11" Name="textBox1" Text="{Binding Path=SelectedItem.CategoryName, Mode=TwoWay}"  /> 
        <TextBox Margin="58,14,64,8" Name="textBox2" Grid.Column="1" Grid.Row="1" Text="{Binding Path=SelectedItem.Description, Mode=TwoWay}"  /> 
    </Grid> 
</Window> 
 

and from the OA project:
<Window x:Class="NWOA.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:my="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"     
    xmlns:local="clr-namespace:NWOA" 
    Title="Northwind OpenAccess" Height="400" Width="575" > 
    <Window.Resources> 
        <ObjectDataProvider x:Key="objectDataProvider" ObjectType="{x:Type local:TestViewModel}"  /> 
    </Window.Resources> 
 
    <Grid DataContext="{Binding Source={StaticResource objectDataProvider}}"> 
        <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="200*" /> 
            <ColumnDefinition Width="300*" /> 
        </Grid.ColumnDefinitions> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="60*" /> 
            <RowDefinition Height="60*" /> 
            <RowDefinition Height="240*" /> 
        </Grid.RowDefinitions> 
        <my:RadGridView  
            Grid.Row="2"  
            Name="radGridView1"  
            Grid.ColumnSpan="2"  
            ColumnsWidthMode="Fill" 
            IsReadOnly="False"  
            SelectedItem="{Binding SelectedItem}" 
            ItemsSource="{Binding CategoryList}"              
        > 
        </my:RadGridView> 
        <TextBlock Margin="91,16,41,10" Name="textBlock1" Text="Name" HorizontalAlignment="Right" VerticalAlignment="Center" /> 
        <TextBlock Margin="91,14,41,8" Name="textBlock2" Grid.Row="1" Text="Description" HorizontalAlignment="Right" VerticalAlignment="Center" /> 
        <TextBox Grid.Column="1" Margin="58,15,64,11" Name="textBox1" Text="{Binding Path=SelectedItem.CategoryName, Mode=TwoWay}"  /> 
        <TextBox Margin="58,14,64,8" Name="textBox2" Grid.Column="1" Grid.Row="1" Text="{Binding Path=SelectedItem.Description, Mode=TwoWay}"  /> 
    </Grid> 
</Window> 
 

They should be identical (other than x:Class=...)

The Window1.xaml.cs files are the same (except for the namespace:
using System.Windows; 
 
namespace NWLinq 
{ 
    public partial class Window1 : Window 
    { 
        public Window1() 
        { 
            InitializeComponent(); 
        } 
    } 
} 
------- 
 
using System.Windows; 
 
namespace NWOA 
{ 
    public partial class Window1 : Window 
    { 
        public Window1() 
        { 
            InitializeComponent(); 
        } 
    } 
} 
 

The viewmodels are as close as can be, based on different requirements for LINQ and OA:
using System.Collections.Generic; 
using System.Linq; 
 
namespace NWLinq 
{ 
    public class TestViewModel 
    { 
        NWLinqDataContext dc = new NWLinqDataContext(); 
        public TestViewModel() 
        { 
            SetTable(); 
        } 
 
        public void SetTable() 
        { 
            var query = 
            from c in dc.Categories select c; 
            CategoryList = query.ToList(); ; 
        } 
 
        public IList<Category> CategoryList 
        { 
            get; 
            set; 
        } 
 
        public Category SelectedItem 
        { 
            get; 
            set; 
        } 
 
    } 
} 
 

using System.Collections.Generic; 
using NWOpenAccess; 
using Telerik.OpenAccess; 
using Telerik.OpenAccess.Query; 
 
namespace NWOA 
{ 
    public class TestViewModel 
    { 
        private IObjectScope scope = NWScopeProvider.GetNewObjectScope(); 
        public TestViewModel() 
        { 
            SetTable(); 
        } 
 
        public void SetTable() 
        { 
            var query = 
            from c in this.scope.Extent<Category>() select c; 
            CategoryList = query.ToList(); ; 
        } 
 
        public IList<Category> CategoryList 
        { 
            get; 
            set; 
        } 
 
        public Category SelectedItem 
        { 
            get; 
            set; 
        } 
 
    } 
} 
 

I won't paste the code for the LINQ designer or the OA designer. Basically, just use the Categories table. From Northwind.

On the grid, moving up and down, the textboxes are updated in both apps.

The problem: If I edit in the grid, the changes are reflected in the textbox for the LINQ program and NOT the OA program.

What am I missing?


A follow up question... what is the best way to save the changes back to the database, and when? When the user moves off the record? When a button is pressed to confirm?












Nedyalko Nikolov
Telerik team
 answered on 13 Aug 2009
1 answer
163 views

Hi.

I'm using a trial version of RadControls for WPF.

I was looking for a way to dynamically "Zoom" in/out a 2D chart( both the x and y axises).

I tried to change TicksDistance value to achieve this goal, but no use.
I thought a refresh might be needed so I added a Dispatcher.Invoke call, and steel no use.

On the AxisY I tried all the above replacing TicksDistance of AxisX with Step property of AxisY.
No use.

If "zooming" is possible in a 2D (Spline series) what is the correct way achieving it?
Thank you
Uriya

code snippet:

 

this

 

 

.mMyChart.RadChart1.DefaultSeriesDefinition = new SplineSeriesDefinition();

 

List

 

<Data> listData = new List<Data>();
for
(int i = 0; i < oc.OctaveNotes.Length; i++)  

 

 

{    listData.Add(

new Data(oc.OctaveNotes[i]));    }

 

this

 

.mMyChart.RadChart1.ItemsSource = listData;

 

 

 

 

 

if

 

(e.Delta > 0)//wheel up  

 

 

{ 

 

 

    Int32 Step = this.mMyChart.RadChart1.DefaultView.ChartArea.AxisX.TicksDistance;  

    Step = Step / 4 * 5; 

 

    this.mMyChart.RadChart1.DefaultView.ChartArea.AxisX.TicksDistance = Step;  

} 

 

else  

{ 

 

    Int32 Step = this.mMyChart.RadChart1.DefaultView.ChartArea.AxisX.TicksDistance; 

    Step = Step / 5 * 4; 

 

    this.mMyChart.RadChart1.DefaultView.ChartArea.AxisX.TicksDistance = Step;  

}


this
.mMyChart.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Render, mEmptyDelegate);

 

 

 

 

 

 

public class Data  

{ 

 

    private DateTime mX; 

 

    public DateTime X  

    { 

 

        get { return mX; } 
       set { mX = value; }  

 

    }

 

 

 

    private Double mY;
    public Double Y

 

    { 

 

 

        get { return mY; } 

 

        set { mY = value; } 

    }

    public

 

Data(NoteInOctave note)  

 

 

 

    {

        mX = note.NoteDateTime; 

 

        Double.TryParse(note.MesuredValue, out mY);  

    }

 

}

 

 

 

Vladimir Milev
Telerik team
 answered on 13 Aug 2009
4 answers
116 views
Just recently I placed two threads on this forum and they have both been taken off! Why??

P
Valentin.Stoychev
Telerik team
 answered on 13 Aug 2009
12 answers
232 views
After uninstalling the 2009 Q1 SP1 release and then installing the 2009 Q1 SP2 release I notice that Telerik's RadControls for WPF does not show in my Vista Home Premium SP2 edition Control Panel/Programs as being installed.

When I went to retry the installation by running the originally downloaded msi I get asked if I want to repair or uninstall the RadControls for WPF. Whichever option I request fails with ".NET 3.5 is not installed" which is patently nonsense. (I am running Visual Studio 2008 SP1 and the Silverlight Controls are installed and working fine). The installation should not be in a state where it cannot be uninstalled or installed and I am now concerned that when the 2009 SP2 release becomes available I will not be able to install it (any install of an existing product invariably stops, insisting that you remove the previous version first).

I would raise a support ticket on this but there's no section I can see for installation. If I click on the WPF controls I'm then required to indicate which specific control I'm raising a support ticket on - which is nonsense of course because I'm raising a ticket on failed installation/clean-up.

Anybody know how I can fix my "working but not uninstallable" control set?

Clint
Top achievements
Rank 1
 answered on 12 Aug 2009
1 answer
553 views
Hi,
I have a GridView with binding to an ObservableCollection in the ViewModel.
The GridView DataLoadMode is set to Asynchronous.
When removing an item from the ObservableCollection in the ViewModel, the GridView is not refershed and item is still shown.
If I set DataLoadMode as synchronous , It works fine.

<telerik:RadGridView  
  x:Name="RadGridViewGroups" 
  Grid.Row="1" 
  AutoGenerateColumns="False" 
  DataLoadMode="Asynchronous" 
  IsReadOnly="True"           
  ItemsSource="{Binding Groups}" > 

public class GroupsViewModel : INotifyPropertyChanged  
{         
    public ObservableCollection<TradingGroup> Groups  
    {  
        get 
        {  
            return m_Groups;  
        }  
        set 
        {  
            m_Groups = value;  
            PropertyChanged.OnPropertyChanged(this, "Groups");  
        }  
    }  
} 


Thanks,
Noam Shoeg



Vlad
Telerik team
 answered on 12 Aug 2009
2 answers
225 views
Hy
I add a CheckBox  column to my grid
and now there is no border to the column
this is the code

<telerik:RadGridView.Resources> 
                    <ControlTemplate x:Key="cellTemplate" TargetType="{x:Type telerik:GridViewCell}">  
                        <CheckBox IsChecked="{Binding Field.Record.Data.Add, RelativeSource={RelativeSource TemplatedParent}}"   
                                                    HorizontalAlignment="Center" VerticalAlignment="Center" /> 
                    </ControlTemplate> 
                    <Style x:Key="booleanCellStyle">  
                        <Setter Property="telerik:GridViewCell.Template" Value="{StaticResource cellTemplate}" /> 
                    </Style> 
                    </telerik:RadGridView.Resources> 

 <telerik:RadGridView.Columns> 
                        <telerik:GridViewDataColumn UniqueName="Add" Header="" Width="Auto" CellStyle="{StaticResource booleanCellStyle}"/>  
                     

Thanks.
Orit
Top achievements
Rank 1
 answered on 12 Aug 2009
8 answers
265 views
Hi,
I am using RadCarousel in WAP Browser Application. I am calling this control in webpart using IFrame tag to run on sharepoint site.
when I deploy it I am getting follwoing error

PLATFORM VERSION INFO
    Windows             : 5.2.3790.131072 (Win32NT)
    Common Language Runtime     : 2.0.50727.3053
    System.Deployment.dll         : 2.0.50727.3053 (netfxsp.050727-3000)
    mscorwks.dll             : 2.0.50727.3053 (netfxsp.050727-3000)
    dfshim.dll             : 2.0.50727.3053 (netfxsp.050727-3000)

SOURCES
    Deployment url            : http://rell:1234/NewXbaps/WPFCarousel03.xbap
    Application url            : http://rell:1234/NewXbaps/WPFCarousel03.exe.manifest

IDENTITIES
    Deployment Identity        : WPFCarousel03.xbap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=09b4372df65d1401, processorArchitecture=msil
    Application Identity        : WPFCarousel03.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=09b4372df65d1401, processorArchitecture=msil, type=win32

APPLICATION SUMMARY
    * Online only application.
    * Browser-hosted application.

ERROR SUMMARY
    Below is a summary of the errors, details of these errors are listed later in the log.
    * An exception occurred while downloading the application. Following failure messages were detected:
        + Downloading http://rell:1234/NewXbaps/WPFCarousel03.exe did not succeed.
        + The remote server returned an error: (415) UNSUPPORTED MEDIA TYPE.
    * An exception occurred while determining trust. Following failure messages were detected:
        + User has refused to grant required permissions to the application.

COMPONENT STORE TRANSACTION FAILURE SUMMARY
    No transaction error was detected.

WARNINGS
    There were no warnings during this operation.

OPERATION PROGRESS STATUS
    No phase information is available.

ERROR DETAILS
    Following errors were detected during this operation.
    * [2/25/2009 6:29:45 PM] System.Deployment.Application.DeploymentDownloadException (Unknown subtype)
        - Downloading http://rell:1234/NewXbaps/WPFCarousel03.exe did not succeed.
        - Source: System.Deployment
        - Stack trace:
            at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
            at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
            at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState)
            at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
            at System.Deployment.Application.DeploymentManager.SynchronizeCore(Boolean blocking)
            at System.Deployment.Application.DeploymentManager.SynchronizeAsyncWorker()
        --- Inner Exception ---
        System.Net.WebException
        - The remote server returned an error: (415) UNSUPPORTED MEDIA TYPE.
        - Source: System
        - Stack trace:
            at System.Net.HttpWebRequest.GetResponse()
            at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
    * [2/25/2009 6:29:46 PM] System.Deployment.Application.TrustNotGrantedException (Unknown subtype)
        - User has refused to grant required permissions to the application.
        - Source: System.Deployment
        - Stack trace:
            at System.Deployment.Application.ApplicationTrust.RequestTrust(SubscriptionState subState, Boolean isShellVisible, Boolean isUpdate, ActivationContext actCtx, TrustManagerContext tmc)
            at System.Deployment.Application.DeploymentManager.DetermineTrustCore(Boolean blocking, TrustParams tp)
            at System.Deployment.Application.DeploymentManager.DetermineTrust(TrustParams trustParams)
            at System.Deployment.Application.InPlaceHostingManager.AssertApplicationRequirements(Boolean grantApplicationTrust)
            at System.Deployment.Application.InPlaceHostingManager.AssertApplicationRequirements()
            at MS.Internal.AppModel.XappLauncherApp.AssertApplicationRequirementsAsync(Object unused)

COMPONENT STORE TRANSACTION DETAILS
    No transaction information is available.


can you tell me what changed i need to do?

Thanks
Vandana
Vlad
Telerik team
 answered on 12 Aug 2009
4 answers
150 views
Hi.
Small problem:
Imagine a class setup of:
public class DisplayData 
{ 
   public string Name { get; set; } 
   public SomeOtherClass Prop { get; set; } 
} 
 
public class SomeOtherClass  
{ 
   public string OtherName { get; set; } 
} 

Now I have an ObservableCollection<DisplayData> to display in my Grid.
Problem is the following setup does no display SomeOtherClass nicely (how should it...)
<telerik:GridViewDataColumn  
     Header="Name" 
     DataMemberBinding="{Binding Path=Name, Mode=OneWay}" 
     Width="2*" 
     IsReadOnly="True"/> 
<telerik:GridViewDataColumn  
     Header="Other" 
     DataMemberBinding="{Binding Path=Prop, Mode=OneWay}" 
     Width="3*" 
     IsReadOnly="True"/> 

If I change the second column like this:
<telerik:GridViewDataColumn   
     Header="Name"  
     DataMemberBinding="{Binding Path=Name, Mode=OneWay}"  
     Width="2*"  
     IsReadOnly="True"/>  
<telerik:GridViewDataColumn   
     Header="Other"  
     DataMemberBinding="{Binding Path=Prop.OtherName, Mode=OneWay}"  
     Width="3*"  
     IsReadOnly="True"/>  

All displays fine. However I loose the Ability to Filter/Group the second column.
I am searching for something like:
<telerik:GridViewDataColumn    
     Header="Name"   
     DataMemberBinding="{Binding Path=Name, Mode=OneWay}"   
     Width="2*"   
     IsReadOnly="True"/>   
<telerik:GridViewDataColumn    
     Header="Other"   
     DataMemberBinding="{Binding Path=Prop, Mode=OneWay}" 
     DisplayMemberPath="OtherName"   
     Width="3*"   
     IsReadOnly="True"/>   

And I can't seem to find any solution..

I seem to walking in the dark here.. so could someone please enlighten me ?

Yours,
Nils
Nils
Top achievements
Rank 1
 answered on 11 Aug 2009
1 answer
228 views
Hello everybody.

We have a RadGridView with 4 columns: 2 are simply text column, while 2 have a button.

The problem we can't figure out is: how we can know the row index number (=item) starting from the button click event?

Thank you for your cooperation.

Attilio Gelosa.
Vlad
Telerik team
 answered on 11 Aug 2009
7 answers
387 views
I am creating tabs on the fly and need to be able to apply a theme to the actual RadTabItem.

I have tried the following with no success:
1) tab1.SetValue(Telerik.Windows.Controls.StyleManager.ThemeProperty, new VistaTheme());
2) Telerik.Windows.Controls.StyleManager.SetTheme(tab1, new VistaTheme());

tab1 is the tab I created:
RadTabItem tab1 = new RadTabItem();

Also, I cannot apply the theme to an existing tab (within the actual XAML) dynamically either.  If a RadTabItem exists with name "tab2" on the xaml form and I try and go and programatically apply a theme somewhere in the code it does not apply at all...

Any help with this would be great.  I really need to be able to apply themes on the fly to dynamically created telerik objects.

Thanks

 

Bobi
Telerik team
 answered on 11 Aug 2009
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
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
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
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
InlineAIAssistant
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?