PDA

View Full Version : کاربرد Template ها و تفاوت اونها با Style؟



sajad_3dmax
پنج شنبه 19 شهریور 1388, 14:21 عصر
با سلام. من یه سری مطلب تو فایلهای PDF راجع به Template خوندم ولی چیزی درباره دلیل استفاده از Template هانفهمیدم . لطفا راهنماییم کنید.:لبخندساده:

رضا عربلو
جمعه 20 شهریور 1388, 15:11 عصر
Style is used to set the properties of an object to particular values. In addition, a Style allows Triggers based on styled object events, styled object property values, and data values. In turn, triggers allow the animation of the object's properties.

In contrast, a Template is used to define the Visual Tree of a Control (ControlTemplate) or the Visual Tree of the representation of an object (DataTemplate). While templates also have Triggers, it is to be noted that Style triggers cannot interract with particular items of the Visual Tree for the object.

One common distinction of Styles and Templates states that a Style can contain one/many Setters/Triggers to change the ControlTemplate or DataTemplate of controls/objects.

sajad_3dmax
شنبه 21 شهریور 1388, 03:38 صبح
Style is used to set the properties of an object to particular values. In addition, a Style allows Triggers based on styled object events, styled object property values, and data values. In turn, triggers allow the animation of the object's properties.

In contrast, a Template is used to define the Visual Tree of a Control (ControlTemplate) or the Visual Tree of the representation of an object (DataTemplate). While templates also have Triggers, it is to be noted that Style triggers cannot interract with particular items of the Visual Tree for the object.

One common distinction of Styles and Templates states that a Style can contain one/many Setters/Triggers to change the ControlTemplate or DataTemplate of controls/objects.
عرض کردم که از رو مرجع لاتین چیزی درباره templateها متوجه نشده بودم .لطفا با زبان شیرین فارسی راهنماییم کنین...:افسرده:

Amir Oveisi
سه شنبه 24 شهریور 1388, 23:42 عصر
با style ها میشه به property ها مقدار دهی کرد و یا trigger کرد. اما نمیشه در Visual Tree اون تغییر ایجاد کرد مثلا نمیشه به یک Button با استفاده از Style خالی یک Image اضافه کرد. برای این کار از Template استفاده میشه.
حالا Template یکی از Property های کنترل هاست و چون با Style میشه به Property ها مقدار داد پس در هر Style میشه Template رو هم تغییر داد.

موفق باشید