Ticket Q489252
Visible to All Users

how to do concatenation in column header of WPF GridControl using xaml

created 12 years ago

Hi DevExpress Team,

how to do concatenation in column header of WPF GridControl using xaml.

<dxg:GridColumn Name="CommandMapped" dxgext:BandedViewBehavior.Row="0" dxgext:BandedViewBehavior.Column="0" dxgext:BandedViewBehavior.ColumnSpan="4" dxgext:BandedViewBehavior.IsBand="True"
Header="{Binding Path=View.FocusedRow.Name, StringFormat='{}{0:CommandsMappedTo}'}">

Thanks,
Sasidhar Muvvala

Comments (2)
DevExpress Support Team 12 years ago

    Hi,
    As I can see in your code snippet, you created a Band column, and this column spans several columns. I'm afraid that the issue is not clear to me. Would you please explain it in greater detail, or provide me with a sample project? I am looking forward to your reply.

    SM SM
    Sasidhar Muvvala 12 years ago

      i have one static value and one dynamic value, i want to bind these two values together in the Header of GridColumn

      Answers approved by DevExpress Support

      created 12 years ago (modified 11 years ago)

      Hello Sasidhar,
      For string concatenation use MultiValueConverter. I have created a simple example of how to solve this issue:

      C#
      public class StringConcatenator : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return String.Concat(values); } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { return new string[] {}; } }
      XAML
      <sys:String x:Key="mappedToString">CommandsMappedTo: </sys:String> <dxs:StringConcatenator x:Key="stringConcatenator"/> <dxg:GridColumn FieldName="Name"> <dxg:GridColumn.Header> <MultiBinding Converter="{StaticResource stringConcatenator}"> <Binding Source="{StaticResource mappedToString}"/> <Binding Path="View.FocusedRow.Name" RelativeSource="{RelativeSource Self}"/> </MultiBinding> </dxg:GridColumn.Header> </dxg:GridColumn>

      A full project is located in the attached archive.

        Show previous comments (7)
        Alex Chuev (DevExpress) 11 years ago

          Hi,
          You can use the following binding:

          XAML
          <dxg:GridColumn FieldName="Name" Header="{Binding FieldName, Converter={local:Converter}, RelativeSource={RelativeSource Self}}"/>

          I've attached a sample demonstrating this approach.
          Hope this helps.

            Thanks a lot, this works for me :-)

            Alex Chuev (DevExpress) 11 years ago

              You are welcome!

              created 12 years ago (modified 12 years ago)

              Hi Sasidhar,
              Thanks for the clarification. I understand what you mean. You are right, you can use the StringFormat property in the binding to add a static string to the resulting value. I've found a link that describes the use of the StringFormat: Trying out Binding.StringFormat. Once you look over it, please let me know if you need further assistance.

                Show previous comments (3)
                SM SM
                Sasidhar Muvvala 12 years ago

                  i am using devexpress grid control… the gridroles is mastergrid…it is not throwing any error…
                  when i used the first approach it is not showing any text
                  when i tried the second approach string concatenation is not working but the dynamic value which is dynamically binded is displaying correctly but its not getting concatenated with the static string

                  SM SM
                  Sasidhar Muvvala 12 years ago

                    pls provide solution

                    Dmitry Tokmachev (DevExpress) 12 years ago

                      Hello,
                      You can find the sample project in the last answer on this page. Please take a moment to review it and let us know if you need further clarification.

                      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.