GridView

2 posts, 0 answers
  1. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 11 Jun 2012 Link to this post

    Hi,

    i found this example to change the CellTemplate. This works fine, but how do i insert a "Passwordbox"?

    <telerik:RadGridView x:Name="RadGridView" AutoGenerateColumns="False" >
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Select hobby" />
                    <telerik:GridViewDataColumn  >
                        <telerik:GridViewDataColumn.CellTemplate>
                            <DataTemplate>
                                <telerik:RadComboBox ItemsSource="{Binding AvailableHobbies}" >
                                    <telerik:RadComboBox.SelectionBoxTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Owner.Choices}" />
                                        </DataTemplate>
                                    </telerik:RadComboBox.SelectionBoxTemplate>
                                    <telerik:RadComboBox.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay}"
                         Content="{Binding Description}" />
                                            </StackPanel>
                                        </DataTemplate>
                                    </telerik:RadComboBox.ItemTemplate>
                                </telerik:RadComboBox>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.CellTemplate>
                    </telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Choices}" />
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>

    With Passwordbox:

    <DataTemplate>
          <StackPanel Orientation="Horizontal">
               <Passwordox Name="Password_txt"  Password="{Binding Password}"  />
          </StackPanel>
    </DataTemplate>

    binding does not work, but why? A simple Textbox ist working fine with this Binding!
    Thanks Best Regards
    Rene

  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 11 Jun 2012 Link to this post

    Hi,

    PasswordBox's Password property is not a dependency property, so that one cannot bind it to a property of his/her ViewModel. Here is a thread from the .NET community forum that sheds some more light on best practices when using PasswordBox.

    All the best,
    Ivan Ivanov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top