Click here to Skip to main content
12,074,808 members (56,793 online)
Rate this:
 
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 10:20am
Comments
Pheonyx 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">

This is just a template to get you started.
  Permalink  
Comments
Eng. Hudhud 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160208.1 | Last Updated 18 Jun 2013
Copyright © CodeProject, 1999-2016
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