tag:blogger.com,1999:blog-8819284282894548281.post6008311980632358595..comments2024-03-29T05:41:22.574+01:00Comments on Bartosz Kosarzycki's blog: Silverlight sdk:DataGrid Column Header DataBinding; How to set DataBinding in Column Header in SilverlightBartosz Kosarzyckihttp://www.blogger.com/profile/17200768831466327121noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-8819284282894548281.post-81781810751245166632014-03-09T20:19:27.403+01:002014-03-09T20:19:27.403+01:00how add 'Contols' , we need to define any ...how add 'Contols' , we need to define any xmlns ?<br /><sdk:DataGridTextColumn Controls:DataGridColumnHelper.HeaderBinding="<br />{Binding Something” />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8819284282894548281.post-62862141816302328542013-01-02T14:40:59.715+01:002013-01-02T14:40:59.715+01:00i am return List<> from the web services and...i am return List<> from the web services and bind that with Data Grid View. And data grid view property is autocolumncreated = true. But i want to change my column name how?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8819284282894548281.post-49785654290577566752012-07-26T11:13:30.245+02:002012-07-26T11:13:30.245+02:00Greatttttttttttttttttttt !
Thanks !!!!!!!!Greatttttttttttttttttttt !<br />Thanks !!!!!!!!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8819284282894548281.post-33559412694747654852012-06-13T21:16:32.849+02:002012-06-13T21:16:32.849+02:00This only seems to work when you are attaching to ...This only seems to work when you are attaching to a static/local resource. if you are trying to bind to something in your datacontext it doesn't appear to work.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8819284282894548281.post-61477682618847991902012-06-13T20:48:15.356+02:002012-06-13T20:48:15.356+02:00Great code! Works in XAML but I have not been abl...Great code! Works in XAML but I have not been able to make it work in code behind. I have to create a dynamic child datagrid withing another datagrid and the column headers need to be bound to localized strings using a custom resources wrapper. <br /><br />The XAML that worked was:<br /><br />DataGridColumnHelper.HeaderBinding="{Binding Source={StaticResource LocTranslation}, Path=LocalizedStrings.Title}"<br /><br />The code behind that I tried was:<br /><br />var b = new Binding();<br />b.Source = new Helpers.CustomResources();<br />b.Path = new PropertyPath("LocalizedStrings.Title");<br />b.Mode = BindingMode.OneWay;<br />DataGridColumnHelper.SetHeaderBinding(column, b);<br /><br />The result is the all to familiar "System.Windows.Data.Binding" instead of the desired binding value.<br /><br />Do you have any idea how to get this to work? Thanks.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8819284282894548281.post-60584497735595299262012-05-22T10:53:38.012+02:002012-05-22T10:53:38.012+02:00Hello, can you please attach to the post some samp...Hello, can you please attach to the post some sample project. I can't make your example work. I had investigate, that DataGridColumn is not part of VisualTree. So I'm curious how you made it works.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8819284282894548281.post-697761277983364272012-03-09T14:54:19.776+01:002012-03-09T14:54:19.776+01:00Good solution! Works well for me..
Thanks!
Juli...Good solution! Works well for me.. <br /><br />Thanks! <br />JulioAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-8819284282894548281.post-38258298442911130342012-03-07T20:29:49.419+01:002012-03-07T20:29:49.419+01:00Hi thanks for your help, but I'm still in pro...Hi thanks for your help, but I'm still in problems with the header binding. I implemented the class, this is it.<br /><br />public static class DataGridColumnHelper<br /> { <br /> public static readonly DependencyProperty HeaderBindingProperty = DependencyProperty.RegisterAttached(<br /> "HeaderBinding",<br /> typeof(string),<br /> typeof(DataGridColumnHelper),<br /> new PropertyMetadata(null, DataGridColumnHelper.OnHeaderBindingPropertyChanged));<br />public static void SetHeaderBinding(DependencyObject dp, string value)<br /> {<br /> dp.SetValue(HeaderBindingProperty, value);<br /> }<br /><br /> public static string GetHeaderBinding(DependencyObject dp)<br /> {<br /> return (string)dp.GetValue(HeaderBindingProperty);<br /> }<br /><br /> private static void OnHeaderBindingPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)<br /> {<br /> DataGridColumn column = sender as DataGridColumn;<br /> if (column == null) { return; }<br /> column.Header = e.NewValue;<br /> }<br /> <br /> }<br /><br />}<br />and in the xaml code I added the property like this:<br /><br /> <br /><br />I don't have any mistake in compilation but when I excecute the application, the header appears empty.<br /><br />I don't know where is the problem. <br />I'll be grateful if you can help me.<br /><br />Thanks.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8819284282894548281.post-83759252139295135372012-03-01T11:08:50.721+01:002012-03-01T11:08:50.721+01:00@Anonymous
"I don't have any idea where t...@Anonymous<br />"I don't have any idea where the helper should be implemented. "<br /><br />Hi.<br />The code actually can be implemented anywhere as it is a static class. You just copy&paste the code for "public static class DataGridColumnHelper". <br />Then you reference this class in xaml where you have your DataGrid. When you create columns (sdk:DataGridTextColumn) instead of writing:<br /><br /><sdk:DataGridTextColumn Header="{Binding someProp}" /><br /><br />which wouldn't work as there would an error: "cannot convert System.Binding to System.String"<br /><br />so you write:<br /><br /><sdk:DataGridTextColumn Controls:DataGridColumnHelper.HeaderBinding="{Binding Something” /><br /><br />and the static class (in particular its dependency property HeaderBinding) writes the data to the header for you.<br />So you write the data to DataGridColumnHelper.HeaderBinding and this class writes it to the sdk:DataGridTextColumn.Header for you automatically. <br /><br />Thanks for the comment.Bartosz Kosarzyckihttps://www.blogger.com/profile/17200768831466327121noreply@blogger.comtag:blogger.com,1999:blog-8819284282894548281.post-13156656047988333752012-02-29T16:25:40.465+01:002012-02-29T16:25:40.465+01:00I didn't work for me.. :(I didn't work for me.. :(Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8819284282894548281.post-72309004670972039222012-02-28T15:47:59.614+01:002012-02-28T15:47:59.614+01:00Hi, I would like to implement this code but I don&...Hi, I would like to implement this code but I don't have any idea where the helper should be implemented. <br />Please give me a little more information about it.<br />Thanks.Anonymousnoreply@blogger.com