Hello,
I've Problems with binding a comman for a Button inside a RadGridView-Column. I'm using the Q3 Release.
This is my XAML:
<telerik:GridViewDataColumn Header="" UniqueName="Product.ProductID" IsReadOnly="True" Background="{StaticResource ProductColumnsBackground}" HeaderCellStyle="{StaticResource DefaultHeaderStyle}">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<Button Margin="2" Command="{Binding Path=DataContext.AddDefectCommand, ElementName=productGrid}" CommandParameter="{Binding }">
<StackPanel Orientation="Horizontal">
<Image RenderOptions.BitmapScalingMode="NearestNeighbor" Width="16" Height="16" Source="../Resources/Defect_16.png"/>
<TextBlock Margin="5" Text="Neuer Mangel"/>
</StackPanel>
</Button>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
"productGrid" is the name of the RadGridView.
I've Problems with binding a comman for a Button inside a RadGridView-Column. I'm using the Q3 Release.
This is my XAML:
<telerik:GridViewDataColumn Header="" UniqueName="Product.ProductID" IsReadOnly="True" Background="{StaticResource ProductColumnsBackground}" HeaderCellStyle="{StaticResource DefaultHeaderStyle}">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<Button Margin="2" Command="{Binding Path=DataContext.AddDefectCommand, ElementName=productGrid}" CommandParameter="{Binding }">
<StackPanel Orientation="Horizontal">
<Image RenderOptions.BitmapScalingMode="NearestNeighbor" Width="16" Height="16" Source="../Resources/Defect_16.png"/>
<TextBlock Margin="5" Text="Neuer Mangel"/>
</StackPanel>
</Button>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
"productGrid" is the name of the RadGridView.
10 Answers, 1 is accepted
0
Michael
Top achievements
Rank 1
answered on 19 Nov 2009, 06:10 AM
Yes.
I'm also having problems with using Command in CellTemplate.
rfComponentLabel is a label control inside View (XAML). This datacontext of view is already set to ViewModel.
I'm also having problems with using Command in CellTemplate.
<telerik:GridViewColumn.CellTemplate> |
<DataTemplate> |
<CheckBox HorizontalAlignment="Center" |
IsChecked="{Binding IsSelected}" |
Command="{Binding ElementName=rfComponentLabel,Path=DataContext.CheckRFComponentCommand}" |
CommandParameter="{Binding}"></CheckBox> |
</DataTemplate> |
</telerik:GridViewColumn.CellTemplate> |
rfComponentLabel is a label control inside View (XAML). This datacontext of view is already set to ViewModel.
0
Hello,
I've just tried ElementBinding in CellTemplate with MS DataGrid and got the same result. You can check the attached project for reference.
Greetings,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I've just tried ElementBinding in CellTemplate with MS DataGrid and got the same result. You can check the attached project for reference.
Greetings,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sternico
Top achievements
Rank 1
answered on 19 Nov 2009, 12:37 PM
Hello,
I don't know the Microsoft DataGrid very well. Before I used the Telerik Grid I used the ListView in this way and it worked fine:
<ListView x:Name="lv1" Grid.Row="2" ItemsSource="{Binding Data}">
<ListView.View>
<GridView>
<GridViewColumn Header="Name">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Action">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Command="{Binding Path=DataContext.AddDefectCommand, ElementName=lv1}" Height="20" Width="20" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
How can I achieve this? I really nedd this functionality.
I don't know the Microsoft DataGrid very well. Before I used the Telerik Grid I used the ListView in this way and it worked fine:
<ListView x:Name="lv1" Grid.Row="2" ItemsSource="{Binding Data}">
<ListView.View>
<GridView>
<GridViewColumn Header="Name">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" VerticalAlignment="Center" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Header="Action">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Command="{Binding Path=DataContext.AddDefectCommand, ElementName=lv1}" Height="20" Width="20" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
How can I achieve this? I really nedd this functionality.
0
Michael
Top achievements
Rank 1
answered on 19 Nov 2009, 01:05 PM
Hi Vlad ,
Could you please try Command? Both my sample and Sternico's sample are using command and we found that its not working.
Could you please try Command? Both my sample and Sternico's sample are using command and we found that its not working.
0
Hi Michael,
I believe that we will get the same result with Command. Most probably this was caused (in both grids) by rows virtualization - ElementName cannot find the element in the logical tree due to missing parent at some stage.
We will try to debug this to see what we can do.
Regards,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I believe that we will get the same result with Command. Most probably this was caused (in both grids) by rows virtualization - ElementName cannot find the element in the logical tree due to missing parent at some stage.
We will try to debug this to see what we can do.
Regards,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Michael
Top achievements
Rank 1
answered on 19 Nov 2009, 02:23 PM
Thanks. It's kinda showstopper for us .. It would be great if we can get the fix as soon as we can.
0
Hello,
I've attached an example project demonstrating how to achieve your goal using RelativeSource FindAncestor for the Binding instead ElementName.
Sincerely yours,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I've attached an example project demonstrating how to achieve your goal using RelativeSource FindAncestor for the Binding instead ElementName.
Sincerely yours,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Michael
Top achievements
Rank 1
answered on 19 Nov 2009, 04:24 PM
Great!!!
Thanks a lot.. You saved my day. Please help me to solve this issue as well http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=260293
I'm thinking to use CRUD Datagrid in one of views. RadGridView doesn't any option like AddNewRow=True so I'm thinking to add new row on button click. But what happened is that RadGridView doesn't show new row even ObserverableCollection which is binded to Grid has changes.
Thanks again.
Thanks a lot.. You saved my day. Please help me to solve this issue as well http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=260293
I'm thinking to use CRUD Datagrid in one of views. RadGridView doesn't any option like AddNewRow=True so I'm thinking to add new row on button click. But what happened is that RadGridView doesn't show new row even ObserverableCollection which is binded to Grid has changes.
Thanks again.
0
Michael
Top achievements
Rank 1
answered on 03 Dec 2009, 04:36 AM
As you suggested, I'm using RelativeSource Binding below . But it doesn't work if this binding is in nested grid. How can I use it in child grid?
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center"
IsChecked="{Binding IsSelected}"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:GridViewDataControl}},Path=DataContext.CheckPaymentMilestoneCommand}"
/>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
0
Hi Michael,
You can specify ancestor level in the logical tree for such bindings. Please check this article for more info:
http://msdn.microsoft.com/en-us/library/ms743599.aspx
Regards,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You can specify ancestor level in the logical tree for such bindings. Please check this article for more info:
http://msdn.microsoft.com/en-us/library/ms743599.aspx
Regards,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.