Click here to Skip to main content
15,887,485 members
Home / Discussions / WPF
   

WPF

 
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 
GeneralRe: Apply Styles To Custom Control Pin
Kevin Marois7-Jul-15 8:18
professionalKevin Marois7-Jul-15 8:18 
Questioncheck out of canvas Pin
ngthtra29-Jun-15 21:36
ngthtra29-Jun-15 21:36 
QuestionProblem in Show/Hide Control in a WPF User Control Pin
Ashfaque Hussain29-Jun-15 20:50
Ashfaque Hussain29-Jun-15 20:50 
AnswerRe: Problem in Show/Hide Control in a WPF User Control Pin
Richard Deeming30-Jun-15 1:10
mveRichard Deeming30-Jun-15 1:10 
GeneralRe: Problem in Show/Hide Control in a WPF User Control Pin
Ashfaque Hussain1-Jul-15 18:54
Ashfaque Hussain1-Jul-15 18:54 
QuestionHiding Few of control in UserControl Pin
Ashfaque Hussain26-Jun-15 0:16
Ashfaque Hussain26-Jun-15 0:16 
Questioni want make Online examination system so which module we used help me .and it work flow of the system Pin
Member 1178790023-Jun-15 18:38
Member 1178790023-Jun-15 18:38 
AnswerRe: i want make Online examination system so which module we used help me .and it work flow of the system Pin
Mycroft Holmes23-Jun-15 20:07
professionalMycroft Holmes23-Jun-15 20:07 
QuestionWPF Expander ExpandDirection Problem Pin
Kevin Marois22-Jun-15 12:56
professionalKevin Marois22-Jun-15 12:56 
AnswerRe: WPF Expander ExpandDirection Problem Pin
Pete O'Hanlon22-Jun-15 19:03
mvePete O'Hanlon22-Jun-15 19:03 
GeneralRe: WPF Expander ExpandDirection Problem Pin
Kevin Marois23-Jun-15 4:21
professionalKevin Marois23-Jun-15 4:21 
GeneralRe: WPF Expander ExpandDirection Problem Pin
Kevin Marois23-Jun-15 5:01
professionalKevin Marois23-Jun-15 5:01 
AnswerRe: WPF Expander ExpandDirection Problem Pin
maddymaddy1428-Jun-15 21:16
maddymaddy1428-Jun-15 21:16 
QuestionGlobal Exception Handling Pin
Kevin Marois19-Jun-15 12:24
professionalKevin Marois19-Jun-15 12:24 
QuestionRe: Global Exception Handling Pin
Richard Deeming22-Jun-15 1:23
mveRichard Deeming22-Jun-15 1:23 

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.