Persistence Manager Issue

6 posts, 0 answers
  1. Alan
    Alan avatar
    32 posts
    Member since:
    Jan 2011

    Posted 22 Oct 2012 Link to this post

    I am using RadGridView for WPF 2012.3.1017.40

    There is some issue with the column header depending on the type of XAML I invoked

    When I use:
    <telerik:GridViewDataColumn UniqueName="Year"  Header="Year" />
    The grid does persists with the expected header "Year"

    However when I use:
    <telerik:GridViewDataColumn UniqueName="Year" >
                        <telerik:GridViewDataColumn.Header>
                            <TextBlock Text="Year" />
                        </telerik:GridViewDataColumn.Header>
                    </telerik:GridViewDataColumn>

    The following is injected into the persisted XML
        <PV Key="12" TypeKey="-664072138">
          <Value xsi:type="xsd:string"<System.Windows.Controls.TextBlock</Value>
        </PV>
    and instead of "Year" in the Column header the grid persists the words "System.Windows.Controls.TextBlock" into the header instead.

    Please note, it appears to be an extra < being injected within the value element. However I need the word "Year" instead.

    How can I fix this?
    Thank you,
    Alan Painter
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 22 Oct 2012 Link to this post

    Hi Alan,

    The Column's Header is an object and you have set it to be a TextBlock. The value persisted is the one returned from Header.ToString() which will return "System.Windows.Controls.TextBlock".
    You will need to change the implementation a little bit and return the Text value for the TextBlock instead of relying on the default ToString() method.

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Alan
    Alan avatar
    32 posts
    Member since:
    Jan 2011

    Posted 22 Oct 2012 Link to this post

    Didie ~

    If I am reading your reply correctly using XAML I am already doing this with:
    <telerik:GridViewDataColumn UniqueName="Year" >
                        <telerik:GridViewDataColumn.Header>
                            <TextBlock Text="Year" />
                        </telerik:GridViewDataColumn.Header>
                    </telerik:GridViewDataColumn>

    And it does not work. Is there something else I need to be doing instead?

    Thank you
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 22 Oct 2012 Link to this post

    Hi,

    I meant that you could change the implementation persisting the values. If you have followed this example, then you could change this code to return the Text of the TextBlock in the Header:

    foreach (GridViewColumn column in gridView.Columns)
    {
        columnProxies.Add(new ColumnProxy()
        {
           UniqueName = column.UniqueName,
        Header = column.Header.ToString(),
          DisplayOrder = column.DisplayIndex,
            Width = column.Width,
      )};
    }

    Another possible solution would be to set the Header like so:
    <telerik:GridViewDataColumn.Header>Year</telerik:GridViewDataColumn.Header>

    All the best,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Alan
    Alan avatar
    32 posts
    Member since:
    Jan 2011

    Posted 25 Oct 2012 Link to this post

    In my situation I will need to apply style properties to the Header.

    For example if I was able to use a TextBlock within the header I would invoke
            <Setter Property="FontFamily" Value="Arial" />
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="FontSize" Value="12" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="TextWrapping" Value="Wrap" />
            <Setter Property="TextAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />

    How can I do this in your example?

    Thank you,
    Alan Painter
  7. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Oct 2012 Link to this post

    Hello Alan,

    You could then return the Text for the TextBlock when you are persisting the value. For example:

    foreach (GridViewColumn column in gridView.Columns)
    {
        columnProxies.Add(new ColumnProxy()
        {
           UniqueName = column.UniqueName,
           Header = (column.Header as TextBlock).Text,
           DisplayOrder = column.DisplayIndex,
           Width = column.Width,
      )};
    }


    All the best,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready