【问题标题】:How to set Z-index of calender control in wpf如何在wpf中设置日历控件的Z-index
【发布时间】:2013-06-13 10:07:12
【问题描述】:

在这里我被困在 wpf 日历控件中。我在 WPF 中使用日历控件但是当我在 TextBox 之类的 GotFocus 事件上调用它时

private void txtjobdate_GotFocus(object sender, RoutedEventArgs e)
        {
            calendar1.Visibility = Visibility.Visible;
        }

它总是显示在其他控件的后面,例如

xaml 代码

<Window x:Class="PhotoSaver.PhotoGraphyJob_Management.AddEditPhotoGraphyJob"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="AddEditPhotoGraphyJob" Height="387" Width="511" xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors">
    <Grid>
        <GroupBox>
            <GroupBox.Header>
                <Label>PhotoGraphy Job</Label>
            </GroupBox.Header>
            <Calendar Height="170"  Name="calendar1" Width="180" Visibility="Hidden" SelectedDatesChanged="calendar1_SelectedDatesChanged" AllowDrop="True" />
        </GroupBox>
        <dxlc:LayoutItem Label="Job Name" Margin="92,39,149,0" Name="JobName" Height="20" VerticalAlignment="Top" LabelPosition="Left" LabelHorizontalAlignment="Center" LabelVerticalAlignment="Center" ElementSpace="5" >
            <dxe:TextEdit Name="txtjobname" />
        </dxlc:LayoutItem>
        <dxlc:LayoutItem Label="Job Date" Margin="96,78,149,0" Name="JobDate" Height="20" VerticalAlignment="Top" LabelPosition="Left" LabelHorizontalAlignment="Center" LabelVerticalAlignment="Center" ElementSpace="5" >
            <dxe:TextEdit Name="txtjobdate" DataContext="{Binding}" GotFocus="txtjobdate_GotFocus" />
        </dxlc:LayoutItem>

        <dxlc:LayoutItem Label="Image Folder" Margin="75,117,149,0" Name="ImageFolder" Height="20" VerticalAlignment="Top" LabelPosition="Left" LabelHorizontalAlignment="Center" LabelVerticalAlignment="Center" ElementSpace="5" >
            <dxe:TextEdit Name="txtimagefolder" />
        </dxlc:LayoutItem>
        <Button Content="Browse" Height="23" HorizontalAlignment="Left" Margin="356,114,0,0" Name="Browse" VerticalAlignment="Top" Width="75" Click="Browse_Click" />
        <Button Content="Update" Height="23" HorizontalAlignment="Left" Margin="151,181,0,0" Name="Update" VerticalAlignment="Top" Width="75" Panel.ZIndex="1" />
        <Button Content="Clear" Height="23" HorizontalAlignment="Left" Margin="265,181,0,0" Name="Clear" VerticalAlignment="Top" Width="75" />
    </Grid>
</Window>

请指导我如何通过在其他控件上方显示日历控件来解决此问题。

希望大家理解我的问题并指导我。

提前致谢。

【问题讨论】:

    标签: c# wpf wpf-controls


    【解决方案1】:

    1) 右键单击​​日历对象 --> 顺序 --> 放在前面。

    2) 或者,只需将 GroupBox 项移动到内部声明的底部 &lt;Grid&gt;(z 顺序是底部(最高)到顶部(最低))。可能有点反直觉。

    【讨论】:

    • @Rahul - 是的,我应该想到这一点。日历在一个组合框中,所以“放在前面”只是把它带到组合框的前面,而不是其他控件的前面。但是,如果您在 GroupBox 上进行,则将其置于前面将起作用(右键单击)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-20
    • 1970-01-01
    • 2013-05-13
    • 2012-02-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多