Home Forums WPF controls Xceed DataGrid for WPF Cell valueConverter

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #22299 |

    I have a column with Type long.
    The CellContentTemplate of the cell is set to:
    <code>
    <mp:LengthConverter x:Key=”LengthConverter”/>
    <DataTemplate x:Key=”LengthCellTemplate”>
    <TextBlock Text=”{Binding Converter={StaticResource LengthConverter}}”/>
    </DataTemplate>

    </code>

    Basically I take the long value (in 32nds of an inch) and displays it as a formated string
    (feet’- inches- fraction”). Works Great
    The length converter has Convert and ConvertBack methods.

    <b>Problem:</b>
    I want to have the user enter a formated string and parse it back to a long(possibly with the convertback method) for the databehind the cell

    I tried celleditor with a textbox as the editor but cant get the bindings right
    Any examples on possible solutions?

    Imported from legacy forums. Posted by MiddleTommy (had 3002 views)

    Xceed Support
    Member
    Post count: 5658

    Look at this thread for details.

    <a href=”http://forums.xceed.com/forums/ShowPost.aspx?PostID=5834#5950″>http://forums.xceed.com/forums/ShowPost.aspx?PostID=5834#5950</a&gt;

    Imported from legacy forums. Posted by Marcus [Xceed] (had 191 views)

    Xceed Support
    Member
    Post count: 5658

    hmmm, the link is not directing you at the proper reply in the thread…

    What you are looking for is in the second page, the 3rd post from the top.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 284 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks
    For everyone else here is the binding-


    <code>
    xmlns:Custom=”http://schemas.xceed.com/wpf/xaml/datagrid&#8221;
    xmlns:xcd=”clr-namespace:Xceed.Wpf.Controls;assembly=Xceed.Wpf.Controls”
    </code>

    <code>
    <Custom:CellEditor x:Key=”LengthCellEditor”>
    <Custom:CellEditor.EditTemplate>
    <DataTemplate>
    <xcd:AutoSelectTextBox Text=”{Binding RelativeSource={RelativeSource FindAncestor,
    AncestorType=Custom:Cell},
    Path=ActualContent,
    UpdateSourceTrigger=PropertyChanged,
    Converter={StaticResource LengthConverter}}”/>
    </DataTemplate>
    </Custom:CellEditor.EditTemplate>
    </Custom:CellEditor>
    </code>

    Imported from legacy forums. Posted by MiddleTommy (had 4329 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.