tags:

views:

452

answers:

2

Hi All, In a WPF UI Application, I have 4 controls and 3 radio buttons( say write, read and load). I have aligned them Properly too.

4 controls are : 1. Tabcontrol with listview in it 2. Stackpanel with checkboxes 3. Stackpanel(orientation - Horizantal) with textbox and browse button 4. A stackpanel with Textblock and Listview.

My question is, for Load RadioButton, I should have all the 4 controls stacked vertically. (this is no issue, its done.. )

for Write button, the controls 2 and 3 should be invisible and the control 1 and 4 should fill tht area.

ctrl ht
1 150
2 100 3 30
4 200

When i press write, the ctrl 2 n 3 shuld become invisible and the ctrl 1 height should be (150 + 75) and ctrl 4 should be (200 + 55).. which makes ctrl1 lower limit should move down to 75 pixels and ctrl 4 upper limit should be 55 pixels above..

please help me in doing this.. I am using XAML and C# for this WPF app

thanks Ramm

A: 

Hi Guys, Even I felt my explanation is confusing. I will provide the xaml code..

I have added all the 4 controls which are stacked vertically.. for rdbtn 1, control 3 shouldnt be available and the control 2 should stretched to down (its upperlimit remains same.. but lower limit should increment) and control 4 (upper limit should stretch up and lower limit remains same.. ) I mean on click of rdbtn 1.. only control 1, 3 and 4 should be seen and occupying the entire space...

Hope I made it clear now :)

Xaml Code :

  <StackPanel Orientation="Vertical" Name="stkPnlParent" Background="OldLace" >
            <Grid >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition  Height="60"/>
                    <RowDefinition Height="220"/>
                    <RowDefinition Height="150"/>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="100"/>
                    <RowDefinition Height="62"/>
                </Grid.RowDefinitions>

Control 1

<GroupBox Grid.Column="0" Grid.Row="0" Header="Browse Data" Name="grpBxBrowseData" >
                    <StackPanel  Orientation="Horizontal">
                        <Label Name="lblBrowseData"  Content="Path :" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="60" Height="30"  ></Label>
                        <TextBox Name="txtBxBrowse" Text="Please enter the path to Browse" HorizontalAlignment="Center" VerticalAlignment="Center" Width="800" Height="30" ></TextBox>
                        <Button  Name="btnBrowseButton"  ToolTip="Browse for Path" HorizontalAlignment="Right" VerticalAlignment="Center" Width="90" Height="30" Margin="30,0,0,0">Browse</Button>
                    </StackPanel>
                </GroupBox>

Control 2

   <TabControl  Grid.Column="0" Grid.Row="1" Name="tbCtrlLaunchInfo" VerticalAlignment="Top" >
                    <TabItem Name ="tbLaunchInfo" HorizontalAlignment="Left" >
                        <TabItem.Header>
                            <StackPanel Orientation="Horizontal">
                                <Label>Launch Informations</Label>
                            </StackPanel>
                        </TabItem.Header>

                        <!--<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Width="Auto">-->

                        <Grid Name="grdLaunchDetails" Height="200" Width="Auto"  HorizontalAlignment="Left" VerticalAlignment="Top">
                            <Grid >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="200"></ColumnDefinition>
                                    <ColumnDefinition Width="660"></ColumnDefinition>
                                    <ColumnDefinition Width="178"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition />
                                </Grid.RowDefinitions>
                            </Grid>


                            <ListView Name="lstviewOfOwners" HorizontalAlignment="Left" >
                                <ListView.View >
                                    <GridView >
                                        <GridViewColumn Header="WorkBook" Width="200" DisplayMemberBinding="{Binding AnyWorkbook}" />
                                        <GridViewColumn Header="Description" Width="660" DisplayMemberBinding="{Binding DescName}" />
                                        <GridViewColumn Header="Date" Width="178" DisplayMemberBinding="{Binding WorkbookDate}" />
                                    </GridView>
                                </ListView.View>
                            </ListView>


                        </Grid>
                        <!--</ScrollViewer>-->
                    </TabItem>
                </TabControl>

Control 3

 <Border Grid.Column="0" Grid.Row="2" Name="brdrTWB" BorderThickness="3" BorderBrush="Brown">

                    <StackPanel  Name="stkPnlCheckBoxes" Orientation="Vertical">

                        <TextBlock Name="txtBlkChekBox" Background="LightBlue" Height="25" Text="Team Work Book" ></TextBlock>

                        <CheckBox  HorizontalAlignment="Left" Width="90" Height="25" Margin="10,0,0,5" >Select All</CheckBox>


                        <StackPanel  Orientation="Horizontal" Height="20" >
                            <CheckBox Margin="10,0,0,0" Height="13.34" HorizontalAlignment="Left" Width="120" >Team Relative Effort</CheckBox>
                        </StackPanel>

                    </StackPanel>
                </Border>

Control 4

 <StackPanel Name="stkPnlLogWindow" Grid.Column="0" Grid.Row="4">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                    <TextBlock Grid.Column="0" Grid.Row="0" Height="25" Background="Honeydew">Team Work Book</TextBlock>
                        <ListView Grid.Column="0" Grid.Row="1" Name="lstviewLogWindow" Height="75" >
                            <ListView.View >
                                <GridView >
                                    <GridViewColumn Header="Date/Time" Width="200" DisplayMemberBinding="{Binding LogWBDateTime}" />
                                    <GridViewColumn Header="Log Details" Width="850" DisplayMemberBinding="{Binding LogWBDetails}" />
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </Grid>
                </StackPanel> </Grid>
Aditya
I am adding the code behind to this .. for referencePlease help me. is that instead of manually setting hte height of the window is bad idea>? in my code behind, I manually setting the height property.. Only events triggering should handle this formatting??
Aditya
A: 
  private void btnwriteData_Checked(object sender, RoutedEventArgs e)
    {
        UpdateReadDataControlVisibility(
                      (bool)btnReadData.IsChecked ? Visibility.Visible : Visibility.Hidden);

        UpdateWriteDataControlVisibility(
            (bool)btnReadData.IsChecked ? Visibility.Hidden : Visibility.Visible);
        lblUploadData.Content = " Upload to:";

        DisableDestinationGridVisibility(
            (bool)btnwriteData.IsChecked ? Visibility.Hidden : Visibility.Visible);


        DisableTeamWBCheckBoxOptions(
         (bool)btnwriteData.IsChecked ? Visibility.Hidden : Visibility.Visible);

        ResizeGridLogWindow(
            (bool)btnwriteData.IsChecked ? lstviewLogWindow.Height = 150 : lstviewLogWindow.Height = 75,


            (bool)btnwriteData.IsChecked ? stkPnlLogWindow.Height = 175 : stkPnlLogWindow.Height = 100);

        btnUpload.Visibility = Visibility.Visible;

        ResizeLaunchInformationWindow(
           (bool)btnwriteData.IsChecked ? tbCtrlLaunchInfo.Height = 295 : tbCtrlLaunchInfo.Height = 220,
           (bool)btnwriteData.IsChecked ? lstviewOfOwners.Height = 275 : lstviewOfOwners.Height = 200,
          (bool)btnwriteData.IsChecked ? grdLaunchDetails.Height = 275 : grdLaunchDetails.Height = 200
           );}

called func's

  private void UpdateWriteDataControlVisibility(Visibility visibility)
    {
        // grdBrowse.Visibility = visibility;
        grpBxBrowseData.Visibility = visibility;
        //btnBrowseButton.Visibility = visibility;
        //txtBxBrowseTB.Visibility = visibility;
        //label1.Visibility = visibility;
        //grpBrowseData.Visibility = visibility;
    }

    private void UpdateReadDataControlVisibility(Visibility visibility)
    {
        grpBxSelectProject.Visibility = visibility;
        // grdSelectProject.Visibility = visibility;
        //label2.Visibility = visibility;
        //comboBoxProject.Visibility = visibility;
        //grpBxLogWindow.Height = 240;
        //grdLogWindow.Height = 230;
    }

    private void DisableDestinationGridVisibility(Visibility visibility)
    {
        stkPnlUpload.Visibility = visibility;
    }

    private void DisableTeamWBCheckBoxOptions(Visibility visibility)
    {
        brdrTWB.Visibility = visibility;
        //brdrTWB.Visibility = visibility;
        //txtBlkTWB.Visibility = visibility;
        //stkPnlTWB.Visibility = visibility;
      //stkpnlFirstRow.Visibility = visibility;
    }

    private void ResizeGridLogWindow(double lstViewHeight, double stkPnlHeight )
    {
        lstviewLogWindow.Height = lstViewHeight;
        stkPnlLogWindow.Height = stkPnlHeight;

    }

    private void ResizeLaunchInformationWindow(double tabHeight, double lstViewHeight, double grdHeight)
    {
        tbCtrlLaunchInfo.Height = tabHeight;
        lstviewOfOwners.Height = lstViewHeight;
        grdLaunchDetails.Height = grdHeight;
    }

** EOM **

Thanks Ramm

Aditya
Please suggest me the better way to solve thisThanksRamm
Aditya