This is a migrated thread and some comments may be shown as answers.

change position & attributes dynamically

1 Answer 66 Views
TileView
This is a migrated thread and some comments may be shown as answers.
Omid reza
Top achievements
Rank 1
Omid reza asked on 15 Apr 2012, 06:00 AM
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>

1 Answer, 1 is accepted

Sort by
0
Accepted
Miro Miroslavov
Telerik team
answered on 18 Apr 2012, 09:46 AM
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 >>

Tags
TileView
Asked by
Omid reza
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
Share this question
or