change position & attributes dynamically

2 posts, 1 answers
  1. Omid reza
    Omid reza avatar
    4 posts
    Member since:
    Apr 2012

    Posted 15 Apr 2012 Link to this post

    i want to create a ranking panel for a race , but when in first time i bind my collection to my radtileview it's work correctly , but after it , if i change one of the attributes , like name , position and etc , does not make any change in radtileview.
    public class pool
        {
            public string _name;
            public string name
            {
                get{return _name;}
                set { _name = value; }
            }
            public int _position;
            public int position
            {
                get { return _position; }
                set { _position = value; }
            }
        }
     
        public partial class MainPage : UserControl
        {
            ObservableCollection<pool> p;
            public MainPage()
            {
                InitializeComponent();
     
                p = new ObservableCollection<pool>();
                for (int i = 0; i < 100; i++)
                {
                    pool pn = new pool();
                    pn.name = "name: " + i.ToString();
                    p.Add(pn);
                }
                tile1.ItemsSource = p;
                tile1.Height = 30 * 102;
                p[2].position += 7;
            }
     
            private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
            {
                p[2].position += 4;
            }
        }
    <UserControl
        x:Class="SilverlightApplication1.MainPage"
        xmlns:my="clr-namespace:SilverlightApplication1"
        Width="640" Height="480">
        <UserControl.Resources>
            <my:posconvert x:Key="posconvert"/>
            <telerik:ContainerBindingCollection x:Key="ContainerBindings">
                <telerik:ContainerBinding PropertyName="Position"
                            Binding="{Binding position, Mode=TwoWay, Converter={StaticResource posconvert}}" />
            </telerik:ContainerBindingCollection>
            <DataTemplate x:Key="pooldata" telerik:ContainerBinding.ContainerBindings="{StaticResource ContainerBindings}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="#" VerticalAlignment="Center" />
                <TextBlock Text="{Binding position}"  VerticalAlignment="Center" />
                <TextBlock Text="{Binding name}" VerticalAlignment="Center" />
            </StackPanel>
        </DataTemplate>
        </UserControl.Resources>
        <Grid x:Name="LayoutRoot" Background="White">
            <ScrollViewer VerticalScrollBarVisibility="Visible" Width="504">
            <telerik:RadTileView MaxColumns="1"  ItemContainerStyle="{StaticResource RadTileViewItemStyle1}" Name="tile1" ItemTemplate="{StaticResource pooldata}"/>
        </ScrollViewer>
            <Button Content="Button" HorizontalAlignment="Right" Margin="0,62,-7,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
        </Grid>
    </UserControl>
  2. Answer
    Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 18 Apr 2012 Link to this post

    Hi Omid reza,

     You should make your classes implement the INotifyPropertyChanged interface in order to update the UI automatically. 

    Greetings,
    Miro Miroslavov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
Back to Top