Click here to Skip to main content
15,911,786 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: SQLite Manager Pin
Richard Andrew x6422-Jul-15 6:36
professionalRichard Andrew x6422-Jul-15 6:36 
GeneralRe: SQLite Manager Pin
Kevin Marois22-Jul-15 6:45
professionalKevin Marois22-Jul-15 6:45 
AnswerRe: SQLite Manager Pin
NickPace22-Jul-15 7:44
NickPace22-Jul-15 7:44 
GeneralRe: SQLite Manager Pin
Kevin Marois22-Jul-15 8:02
professionalKevin Marois22-Jul-15 8:02 
GeneralRe: SQLite Manager Pin
Mycroft Holmes22-Jul-15 14:22
professionalMycroft Holmes22-Jul-15 14:22 
GeneralRe: SQLite Manager Pin
Richard MacCutchan22-Jul-15 22:18
mveRichard MacCutchan22-Jul-15 22:18 
AnswerRe: SQLite Manager Pin
Pete O'Hanlon22-Jul-15 22:49
mvePete O'Hanlon22-Jul-15 22:49 
GeneralRe: SQLite Manager Pin
Kevin Marois23-Jul-15 3:50
professionalKevin Marois23-Jul-15 3:50 
QuestionDataBinding to an Icon Pin
Member 1027274820-Jul-15 8:23
Member 1027274820-Jul-15 8:23 
AnswerRe: DataBinding to an Icon Pin
Herman<T>.Instance23-Jul-15 11:31
Herman<T>.Instance23-Jul-15 11:31 
GeneralRe: DataBinding to an Icon Pin
Member 1027274824-Jul-15 1:36
Member 1027274824-Jul-15 1:36 
QuestionWPF Expander - Change Image Pin
Kevin Marois15-Jul-15 6:29
professionalKevin Marois15-Jul-15 6:29 
QuestionCustom Drop Down Menu Button Pin
Kevin Marois7-Jul-15 8:05
professionalKevin Marois7-Jul-15 8:05 
AnswerRe: Custom Drop Down Menu Button Pin
Richard Deeming7-Jul-15 11:36
mveRichard Deeming7-Jul-15 11:36 
GeneralRe: Custom Drop Down Menu Button Pin
Kevin Marois7-Jul-15 11:42
professionalKevin Marois7-Jul-15 11:42 
QuestionApply Styles To Custom Control Pin
Kevin Marois7-Jul-15 5:36
professionalKevin Marois7-Jul-15 5:36 
AnswerRe: Apply Styles To Custom Control Pin
Richard Deeming7-Jul-15 6:57
mveRichard Deeming7-Jul-15 6:57 
GeneralRe: Apply Styles To Custom Control Pin
Kevin Marois7-Jul-15 7:03
professionalKevin Marois7-Jul-15 7:03 
GeneralRe: Apply Styles To Custom Control Pin
Richard Deeming7-Jul-15 7:07
mveRichard Deeming7-Jul-15 7:07 
GeneralRe: Apply Styles To Custom Control Pin
Kevin Marois7-Jul-15 7:10
professionalKevin Marois7-Jul-15 7:10 
GeneralRe: Apply Styles To Custom Control Pin
Richard Deeming7-Jul-15 7:13
mveRichard Deeming7-Jul-15 7:13 
GeneralRe: Apply Styles To Custom Control Pin
Kevin Marois7-Jul-15 7:19
professionalKevin Marois7-Jul-15 7:19 
GeneralRe: Apply Styles To Custom Control Pin
Richard Deeming7-Jul-15 7:41
mveRichard Deeming7-Jul-15 7:41 
Kevin Marois wrote:
If in the User Control library I created a reference to the app, that makes that User Control library bound forever to that one app.

I'm not talking about the UC project having a reference to the application. I'm talking about the "shared styles" project having a reference to the UC project.

The "shared styles" project is the one that's defining the styles for the controls in the UC project, so that's the one that needs a reference to the UC project.

Kevin Marois wrote:
There has to be a way in the form it's on to say "Set the combo boxes to use TimerPickerComboStyle" ...

You could expose a dependency property typed as Style, and bind that to the child control's Style property in the OnApplyTemplate method.
C#
public static readonly DependencyProperty ComboBoxStyleProperty = DependencyProperty.Register(
    "ComboBoxStyle", typeof(Style), typeof(TimePicker));

public Style ComboBoxStyle
{
    get { return (Style)GetValue(ComboBoxStyleProperty); }
    set { SetValue(ComboBoxStyleProperty, value); }
}

private BindingBase GetTimePickerBinding(DependencyProperty property)
{
    return new Binding(property.Name)
    {
        Source = this
    };
}
 
public override void OnApplyTemplate()
{
    base.OnApplyTemplate();
    
    var comboBox = GetTemplateChild("PART_FirstCombo") as ComboBox;
    if (comboBox != null)
    {
        comboBox.SetBinding(FrameworkElement.StyleProperty, 
            GetTimePickerBinding(ComboBoxStyleProperty));
    }
}

You could then set the combo-box style each time you used the control:
XAML
<uc1:TimePicker
    ComboBoxStyle="{StaticResource TimePickerComboStyle}"
/>

Or in a global style within the application:
XAML
<Style TargetType="{x:Type uc1:TimePicker}">
    <Setter Property="ComboBoxStyle" Value="{StaticResource TimePickerComboStyle}" />
</Style>

However, you still wouldn't be able to specify this in a global style from the "shared styles" project unless that project had a reference to the UC project.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Apply Styles To Custom Control Pin
Kevin Marois7-Jul-15 7:55
professionalKevin Marois7-Jul-15 7:55 
GeneralRe: Apply Styles To Custom Control Pin
Richard Deeming7-Jul-15 8:17
mveRichard Deeming7-Jul-15 8:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.