1
Vote

MaskedTextBox does not bind inside listview

description

Hi,
 
MaskedTextBox does not bind when placed inside a listview. It works ok on a simple window.
 
Here is the code:
 
public partial class MaskedTextBoxTest : Window
{
    public MaskedTextBoxTest()
    {
        InitializeComponent();
        List<Test> Tests = new List<Test>();
        Test test = new Test();
        Tests.Add(test);
        cGrid.ItemsSource = Tests;
    }
}
public class Test
{
    private string _LastVisit = "";
    public string LastVisit
    {
        get
        {
            return System.DateTime.Today.ToString("dd/MM/yyyy");
        }
        set
        {
            _LastVisit = value;
        }
    }
}
 
 
XAML::
 
<ListView x:Name="cGrid">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="" Width="30">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Controls:MaskedTextBox Mask="00/00/0000" Width="100">
                            <Binding Path="LastVisit" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"/>
                            </Controls:MaskedTextBox>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>

comments