元素绑定在WPF中ToggleButton的上下文菜单中不起作用
我已经向这样的切换按钮添加了一个ContextMenu元素绑定在WPF中ToggleButton的上下文菜单中不起作用,wpf,contextmenu,togglebutton,Wpf,Contextmenu,Togglebutton,我已经向这样的切换按钮添加了一个ContextMenu <ToggleButton x:Name="ToggleButtonDateRange" Grid.Column="2" FontFamily="{icoMoon:IcoMoonFont}" FontSize="15" Template="{StaticResource DateRangeToggleButtonTemplate}"> <To
<ToggleButton x:Name="ToggleButtonDateRange" Grid.Column="2" FontFamily="{icoMoon:IcoMoonFont}" FontSize="15" Template="{StaticResource DateRangeToggleButtonTemplate}">
<ToggleButton.Style>
<Style BasedOn="{StaticResource ChromelessButton}" TargetType="ToggleButton">
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="ContextMenu" Value="{StaticResource DateRangeContextMenu}" />
</Trigger>
</Style.Triggers>
</Style>
</ToggleButton.Style>
<i:Interaction.Behaviors>
<behaviors:DropDownToggleButtonMenuBehavior/>
</i:Interaction.Behaviors>
</ToggleButton>
ContextMenu的定义如下:
<ContextMenu x:Key="DateRangeContextMenu" Style="{StaticResource DropdownCalendarContextMenuStyle}">
<Grid Background="{StaticResource BrushBackgroundLight}">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
Today Button
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="50"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<RadioButton x:Name="FromTab" Grid.Column="0" Style="{StaticResource TabControl}" Content="{Binding ElementName=FromCalendar, Path=SelectedDate}" GroupName="TabGroup" IsChecked="True" />
<TextBlock Grid.Column="1" Text="{icoMoon:IcoMoon ArrowForward}" FontFamily="{icoMoon:IcoMoonFont}"
VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" FontSize="15"
Foreground="{StaticResource DarkSlateGrayBackgroundColor}"/>
<RadioButton x:Name="ToTab" Grid.Column="2" Style="{StaticResource TabControl}" Content="{Binding ElementName=ToCalendar, Path=SelectedDate}" GroupName="TabGroup" />
</Grid>
<Border Grid.Row="1" Visibility="{Binding ElementName=FromTab, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}">
<Viewbox>
<controls:CalendarAutoDefocus x:Name="FromCalendar" Background="{StaticResource BrushContentWhite}" BorderThickness="0"
SelectedDate="{Binding SearchStartDate}" DisplayDateEnd="{Binding ElementName=ToCalendar, Path=SelectedDate}" DisplayDate="{Binding CalendarStartDisplayDate}"
SingleClickDefocus="False"/>
</Viewbox>
</Border>
<Border Grid.Row="1" Visibility="{Binding ElementName=ToTab, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}">
<Viewbox>
<controls:CalendarAutoDefocus x:Name="ToCalendar" Background="{StaticResource BrushContentWhite}" BorderThickness="0"
SelectedDate="{Binding SearchEndDate}" DisplayDateStart="{Binding ElementName=FromCalendar, Path=SelectedDate}" DisplayDate="{Binding CalendarEndDisplayDate}"
SingleClickDefocus="False"/>
</Viewbox>
</Border>
</Grid>
</ContextMenu>
今天按钮
问题:
Tab和ToTab中的单选按钮不绑定到Calendar和ToCalendar中的元素
我们如何解决元素绑定问题
请帮忙
谢谢,
SathSelectedDate属性是一个布尔对象,您正在绑定到radiobutton?嗨,Aakansksha!SelectedDate是一个日期属性,单选按钮已重新模板化以显示SelectedDate值。谢谢。:)您的FromCalendar元素已选择日期属性?