Hi,
I am wanting to know if its possible to retrieve the actual height of the timeslotpresenter, I can do it in code behind using the infragistics utilities but am trying to do it in xaml using a multibinding, however I can't seem to figure out what to reference as ancestor. This is what I tried to do.
<MultiBinding Converter="{x:Static valueConverters:SizeConverter.Instance}">
<Binding Path="DateFrom" />
<Binding Path="DateTo" />
<Binding Path="TimeslotInterval" ElementName="DayView" />
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type ig:XamDayView:TimeslotPresenter}}"/>
</MultiBinding>
Any help would be appreciated.
kind regards,
Anne
Hello Anne,
Let me know if you have any further questions on this matter.
Hi Anne,
Ok I understand now. I don't think this is possible through a binding though. FindAncestor will only traverse up the VisualTree starting with the control where the binding is located. The binding is located inside the Rectangle so it will start there and then move up the VisualTree from parent to parent. Since the control where this binding is located is not present anywhere inside a TimeslotPresenter, it's never going to find one.
I can't think of any binding that will allow you to travel to another control from within a different control. ElementName is the closest I can see but this won't work since it's dependent on the scope of the current binding. Using ElementName here would only give you access to controls in the same scope as the Rectangle. Anything outside the DataTemplate won't be accessible.
Therefore I believe the best approach you can use is the one you have already, by doing this in code behind. In code behind, you can grab the XamDayView and use the Infragistics.Windows.Utilities.GetDescendantFromType method to traverse down it's VisualTree and grab a TimeslotPresenter.
Hi Rob,
Thank you for your speedy reply, I have created a 'custom control' if you will, and it shows the status of items, e.g. from 10:00 - 12:00 shows in green, I want to make these 'timeslots' the same height per interval as the diary timeslots so that it is not confusing for the user as they have the diary on the same screen. Here is the full code:
<ItemsControl ItemsSource="{Binding Data}" Width="50" >
<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer Padding="{TemplateBinding Padding}" Width="50" x:Name="Scroller" CanContentScroll="True" >
<ItemsPresenter />
</ScrollViewer>
/ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" ></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Rectangle Fill="{Binding Brush}" Width="84" >
<Rectangle.Height>
<Binding Path="Height" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type igPrim:TimeslotPresenter}}"/>
</Rectangle.Height>
</Rectangle>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
So if you imagine on the left of screen I have xamdayview functioning as normal and on the right is this control, the two don't work together at all, or I am wanting to do is get the height of the timeslotpresenter used in the dayview to pass into my converter for a custom calculation I have and then to colour my custom control as needed. So I am just trying to get a bind to the timeslotpresenter. As I said in my previous message I can do this via code behind but was just wondering if its not possible to do in a binding.
I have looked at this example
http://ko.infragistics.com/community/forums/p/86469/431308.aspx
From within what control are you using this MultiBinding? Is it inside a TimeslotPresenter or some other control. If it's inside a Style setter for the Template of a TimeslotPresenter then you can just use {RelativeSource TemplatedParent} as the binding.
I need to know more about how you are using this MultiBinding and where it is located.