Модераторы: gambit, Kefir, Partizan
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> Смена дизайна на лету 
V
    Опции темы
gambit
Дата 2.9.2010, 14:48 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
***
Награды: 1



Профиль
Группа: Комодератор
Сообщений: 1359
Регистрация: 25.6.2006
Где: я?

Репутация: нет
Всего: 40



Добрый день, скажите в какую сторону копать, или если можно то небольшое пример.

Есть форма, у нее применен стиль, на ней кнопка. Нажили на кнопку, стиль сменился на другой, нажали на другую кнопку, вернулся первый стиль.
Покажите пож, маленький пример, пусть пока в стилях прописана какая ниб мелочь, типа цвета фона.
Спасибо.
PM MAIL ICQ Skype   Вверх
Kaerus
Дата 5.9.2010, 20:45 (ссылка) |    (голосов:1) Загрузка ... Загрузка ... Быстрая цитата Цитата


WPF'er
*


Профиль
Группа: Участник
Сообщений: 89
Регистрация: 3.9.2010

Репутация: 1
Всего: 1



Советую просмотреть исходники WPF Themes - http://wpfthemes.codeplex.com/SourceControl/list/changesets
Там в комплекте с темами пример приложения с заменами темы на лету

Вот кусок кода по замене тем (на все приложение и на отдельный конторол):
Код

        public static void ApplyTheme(this Application app, string theme)
        {
            ResourceDictionary dictionary = ThemeManager.GetThemeResourceDictionary(theme);

            if (dictionary != null)
            {
                app.Resources.MergedDictionaries.Clear();
                app.Resources.MergedDictionaries.Add(dictionary);
            }
        }

        public static void ApplyTheme(this ContentControl control, string theme)
        {
            ResourceDictionary dictionary = ThemeManager.GetThemeResourceDictionary(theme);

            if (dictionary != null)
            {
                control.Resources.MergedDictionaries.Clear();
                control.Resources.MergedDictionaries.Add(dictionary);
            }
        }

PM MAIL ICQ   Вверх
CasperSC
Дата 16.10.2010, 23:02 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Бывалый
*


Профиль
Группа: Участник
Сообщений: 203
Регистрация: 27.11.2009

Репутация: 1
Всего: 1



Цитата(Kaerus @ 5.9.2010,  20:45)
Советую просмотреть исходники WPF Themes - http://wpfthemes.codeplex.com/SourceControl/list/changesets
Там в комплекте с темами пример приложения с заменами темы на лету


Кто нибудь в курсе можно ли эти шаблоны использовать в своём приложении? Просто я не мега гуд англичанин, не полностью понял всётаки можно или нельзя использовать в своём приложении?

Код

Microsoft Public License (Ms-PL)

This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.

1. Definitions

The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law.

A "contribution" is the original software, or any additions or changes to the software.

A "contributor" is any person that distributes its contribution under this license.

"Licensed patents" are a contributor's patent claims that read directly on its contribution.

2. Grant of Rights

(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.

(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.

3. Conditions and Limitations

(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.

(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically.

(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software.

(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license.

(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.



И по теме. Можно например одному или какому-то кол-ву поменять шаблоны (так для разнообразия, пусть будет =) ):
Код

        Boolean changed;        

        private void btnChangeStyle_Click(object sender, RoutedEventArgs e)
        {
            if (!changed)
            {
                ControlTemplate template = (ControlTemplate)Application.Current.FindResource("ButtonControlTemplate2");
                this.btnChangeStyle.Template = template;
                changed = !changed;
            }
            else
            {
                ControlTemplate template = (ControlTemplate)Application.Current.FindResource("ButtonControlTemplate1");
                this.btnChangeStyle.Template = template;
                changed = !changed;
            }
         }


Это сообщение отредактировал(а) CasperSC - 16.10.2010, 23:04
PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | WPF и Silverlight | Следующая тема »


 




[ Время генерации скрипта: 0.0561 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.