How to set Z-index of calender control in wpf

点点圈 提交于 2019-12-11 19:25:22

问题


Here i am stuck in wpf calender control.I am using a calender control in WPF but when i call it on GotFocus event of TextBox like

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

It always show behind the other controls like

xaml code

<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>

Please guide me that how i can solve this problem by showing calender control above the other controls.

Hope you all understand my question and guide me.

Thanks in advance.


回答1:


1) Right click the calendar object --> Order --> Bring to front.

2) Alternatively, just move the GroupBox item to the bottom of the declarations inside the <Grid> (z-order is bottom (highest) to top (lowest)). Perhaps a bit counterintuitive.



来源:https://stackoverflow.com/questions/17084359/how-to-set-z-index-of-calender-control-in-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!