Click here to Skip to main content
11,720,785 members (83,812 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WPF
Hi , I have a resource dictionary which has dependency property like that:

<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:dp="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TestFromDb.Controls">
 
    <Style TargetType="{x:Type local:CalendarTimeslotItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:CalendarTimeslotItem}">
                    <Border removed="{TemplateBinding Background}"
                            BorderBrush="#A5BFE1"
                            BorderThickness="0,0.5,0,0.5"
                            x:Name="bd"
                            Height="22">
                        <Border CornerRadius="4,4,4,4" BorderThickness="1,1,1,1" BorderBrush="#5D8CC9" x:Name="hover"
                                Opacity="0" removed="#10000000">
                            <TextBlock Text="Click to add appointment" HorizontalAlignment="Center" 
                                       VerticalAlignment="Center" Foreground="#A39DD8" />
                        </Border>

what I want to do is send my selected date from date picker to this dependency property class, but it doesn't work, can anyone help me & till me what I miss please.
thanks.
Posted 18-Jun-13 9:20am
Comments
Pheonyx at 18-Jun-13 16:45pm
   
I dont really understand why you have tried to do this? Would you not be better off making a user control rather than some strange resource dictionary? Then your user control can actually have this custom dependency property which could in turn be used for data binding?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Your first problem is that you have nothing to bind to. What you should be doing is using ListBox instead of StackPanel. Then you can Bind to the SelectedItem property. If you do not like the container for the default ListBox, then you override the ItemsPanel, and you can also override the default ItemTemplate:
<listbox name="ListBoxAvailablePickedBrokers">
	ItemsSource="{Binding AvailablePickedBrokers}"
	BorderThickness="0"
	Background="Transparent"
	Margin="-15,15,-15,0"
	MaxHeight="168">
	<listbox.itemspanel>
		<itemspaneltemplate>
			<wrappanel orientation="Horizontal">
			 HorizontalAlignment="Stretch"
			 Width="480"
			 Background="Transparent" />
		</wrappanel></itemspaneltemplate>
	</listbox.itemspanel>
	<listbox.itemtemplate>
		<datatemplate>
			<button content="{Binding BrokerId}">
					ToolTip="{Binding BrokerName}"
					Width="39"
		Command="{Binding DataContext.PickedBrokerSelection, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
				CommandParameter="{Binding BrokerId}"						Click="PickedBrokerButton_OnClick"
				Margin="-.75,.25" />
		</button></datatemplate>
	</listbox.itemtemplate>
</listbox>

This is just a template to get you started.
  Permalink  
Comments
Eng. Hudhud at 19-Jun-13 4:50am
   
Clifford Nelson : I want to bind to date from datepicker so I think listbox will not help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 2,179
1 OriginalGriff 924
2 F-ES Sitecore 640
3 Maciej Los 609
4 Richard MacCutchan 540


Advertise | Privacy | Mobile
Web01 | 2.8.150901.1 | Last Updated 18 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100