We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to make a simple WPF Databinding in DataTemplate in GridTreeControl?

Thread ID:

Created:

Updated:

Platform:

Replies:

113865 Oct 14,2013 02:32 AM Oct 18,2013 11:32 PM WPF 1
loading
Tags: GridControl
Christian Schmitt
Asked On October 14, 2013 02:32 AM

Good Morning,

i evaluate the Syncfusion WPF Controls for our Company. We are very interessted in the GridTreeControl but i have many Problems to get the GridTreeControl work for me. The Samples are always works with Behaviours and much C# Code instead of XAML and the Documentation is not really meaningful =(

So back to Topic: I will make a simple DataBinding in a CellTemplate but no chance ....

Here is my XAML Code:

<Window x:Class="Syncfusion.TestClient.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:Syncfusion.TestClient.ViewModel"
xmlns:syncfusion="clr-namespace:Syncfusion.Windows.Controls.Grid;assembly=Syncfusion.Grid.Wpf"
Title="MainWindow"
Height="350"
Width="1173">
<Window.DataContext>
<vm:MainWindowViewModel />
</Window.DataContext>
<Window.Resources>
<DataTemplate x:Key="sliderTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock FontWeight="Bold"
  Text="{Binding CellBoundValue}" />
<CheckBox IsChecked="{Binding CellValue2.IsAggregationValue}" />
<TextBlock Text="{Binding CellValue.IsAggregationValue}" />
</StackPanel>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="55*" />
<ColumnDefinition Width="9*" />
</Grid.ColumnDefinitions>

<syncfusion:GridTreeControl x:Name="treeGrid"
ExpandStateAtStartUp="AllNodesExpanded"
ReadOnly="True"
ItemsSource="{Binding TreeDataViewModels}"
ChildPropertyName="SubTreeDataItems"
ExpandGlyphType="PlusMinusLines"
UpdateMode="PropertyChanged"
Margin="10">

<syncfusion:GridTreeControl.Columns>
<syncfusion:GridTreeColumn Width="150"
  PercentWidth="0.5"
  MappingName="Description">
</syncfusion:GridTreeColumn>
<syncfusion:GridTreeColumn Width="110"
  PercentWidth="0.5"
  MappingName="Quantity" />
<syncfusion:GridTreeColumn Width="110"
  PercentWidth="0.5"
  MappingName="Unit" />
<syncfusion:GridTreeColumn Width="120"
  PercentWidth="0.5"
  MappingName="Price" />

<syncfusion:GridTreeColumn MappingName="Price">
<syncfusion:GridTreeColumn.StyleInfo>
<syncfusion:GridDataStyleInfo CellType="DataBoundTemplate"
 CellEditTemplate="{StaticResource sliderTemplate}"
 CellItemTemplate="{StaticResource sliderTemplate}"/>
</syncfusion:GridTreeColumn.StyleInfo>
</syncfusion:GridTreeColumn>
<syncfusion:GridTreeColumn Width="120"
  PercentWidth="0.5"
  MappingName="AggregatedPrice" />

<syncfusion:GridTreeColumn Width="120"
  PercentWidth="0.5"
  MappingName="Currency" />

<syncfusion:GridTreeUnboundColumn Expression="Quantity*Price"
 HeaderText="Grand Total"
 MappingName="GrandTotal"
 PercentWidth="2">

<syncfusion:GridTreeUnboundColumn.StyleInfo>

<syncfusion:GridStyleInfo HorizontalAlignment="Right"
 CellType="CurrencyEdit" />

</syncfusion:GridTreeUnboundColumn.StyleInfo>

</syncfusion:GridTreeUnboundColumn>
</syncfusion:GridTreeControl.Columns>
</syncfusion:GridTreeControl>
</Grid>
</Window>


I tried to Bind in the Template to:
<CheckBox IsChecked="{Binding CellValue.IsAggregationValue}" />
<CheckBox IsChecked="{Binding CellValue2.IsAggregationValue}" />
<CheckBox IsChecked="{Binding ModelStyle.CellValue.IsAggregationValue}" />
<CheckBox IsChecked="{Binding ModelStyle.CellValue2.IsAggregationValue}" /> (like the ToolTipSample with the Cars)
<CheckBox IsChecked="{Binding IsAggregationValue}" />
<CheckBox IsChecked="{Binding CellBoundValue.IsAggregationValue}" />

Nothing Works!

public ObservableCollection<TreeDataViewModel> TreeDataViewModels

  public class TreeDataViewModel : INotifyPropertyChanged
    {
....
 private bool isAggregationValue;
        public bool IsAggregationValue
        {
            get { return isAggregationValue; }
            set
            {
                isAggregationValue = value;
                OnPropertyChanged("IsAggregationValue");
            }
        }

....
}

Can you help me please?

Gobinath A [Syncfusion]
Replied On October 18, 2013 11:32 PM

Hi Christian,

Thanks for using syncfusion products.

We have analyzed the reported issue in different scenario but we are unable to reproduce the issue. Could you please check the below sample?

Sample: Minimal Tree Demo1.zip

We suspect you are using our grid in some other scenario, So If possible could you please modify our sample and revert us with replication procedure, that would be very helpful to resolve your problem earlier.

Please let us know if you have any queries,

Regards,

Gobinath A


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;