第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

WPF 網(wǎng)格列 def auto 始終從右側(cè)剪切

WPF 網(wǎng)格列 def auto 始終從右側(cè)剪切

C#
倚天杖 2023-07-09 17:27:59
我有一個(gè) WPF 應(yīng)用程序,其中有一個(gè)網(wǎng)格,其中 2 列設(shè)置為 * 和自動。問題是,當(dāng)我減小窗口的大小時(shí),第二列中的子項(xiàng)將從右側(cè)而不是左側(cè)被剪切。我希望它們從左側(cè)剪輯,因?yàn)槲乙褜⑺綄R設(shè)置為右側(cè)。有沒有辦法可以剪切左側(cè)的第二列元素?<Window x:Class="WpfApp2.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"        xmlns:local="clr-namespace:WpfApp2"        mc:Ignorable="d"        Title="MainWindow" Height="450" Width="800" >    <Grid>        <Grid.ColumnDefinitions>            <ColumnDefinition Width="*" MinWidth="60"/>            <ColumnDefinition Width="auto"/>        </Grid.ColumnDefinitions>        <DockPanel  HorizontalAlignment="Right" Grid.Column="1">            <Button Click="Button_Click" Content="click me" Width="150" DockPanel.Dock="Right" />            <Label Content="abcdef" Width="200" DockPanel.Dock="Right" />            <Label x:Name="mLog"/>        </DockPanel>        <Button Click="Button_Click" DockPanel.Dock="Right" Content="click me" Width="150"/>        <Label Content="abcdef" Width="200" DockPanel.Dock="Right"/>    </Grid></Window>
查看完整描述

3 回答

?
紅顏莎娜

TA貢獻(xiàn)1842條經(jīng)驗(yàn) 獲得超13個(gè)贊

 而不是這個(gè):


<Window x:Class="WpfApp2.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

        xmlns:local="clr-namespace:WpfApp2"

        mc:Ignorable="d"

        Title="MainWindow" Height="450" Width="800" >

    <Grid>

        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="*" MinWidth="60"/>

            <ColumnDefinition Width="auto"/>

        </Grid.ColumnDefinitions>

        <DockPanel  HorizontalAlignment="Right" Grid.Column="1">

            <Button Click="Button_Click" Content="click me" Width="150" DockPanel.Dock="Right" />

            <Label Content="abcdef" Width="200" DockPanel.Dock="Right" />

            <Label x:Name="mLog"/>

        </DockPanel>

        <Button Click="Button_Click" DockPanel.Dock="Right" Content="click me" Width="150"/>

        <Label Content="abcdef" Width="200" DockPanel.Dock="Right"/>

    </Grid>

</Window>

嘗試這個(gè):


<Window x:Class="WpfApp2.MainWindow"

            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

            xmlns:local="clr-namespace:WpfApp2"

            mc:Ignorable="d"

            Title="MainWindow" Height="450" Width="800" >

        <Grid>

            <Grid.ColumnDefinitions>

                <ColumnDefinition Width="*" MinWidth="60"/>

                <ColumnDefinition Width="auto"/>

            </Grid.ColumnDefinitions>

            <DockPanel  HorizontalAlignment="Right" Grid.Column="1">

                <Button Click="Button_Click" Content="click me" Width="150" DockPanel.Dock="Right" />

                <Label Content="abcdef" Width="200" DockPanel.Dock="Right" />

                <Label x:Name="mLog"/>

            </DockPanel>

            <Button Click="Button_Click" DockPanel.Dock="Right" Content="click me"/>

            <Label Content="abcdef" Width="200" DockPanel.Dock="Right"/>

        </Grid>

    </Window>

我刪除了最后一個(gè)按鈕寬度屬性。


查看完整回答
反對 回復(fù) 2023-07-09
?
呼如林

TA貢獻(xiàn)1798條經(jīng)驗(yàn) 獲得超3個(gè)贊

我猜你正在嘗試制作 3 列布局,兩側(cè)各有 1 個(gè)按鈕,中間有 1 個(gè)內(nèi)容通道。


因此,您可以嘗試這樣的操作,其中所有內(nèi)容都位于具有不同 z-index 和水平對齊的同一網(wǎng)格中,現(xiàn)在,當(dāng)您調(diào)整窗口大小時(shí),標(biāo)簽保持在中間,按鈕“夾在”標(biāo)簽內(nèi)容的右側(cè)和后面左邊。


<Grid>

    <Button HorizontalAlignment="Left" Content="click me" Width="150" />

    <Button HorizontalAlignment="Right" Content="click me" Width="150" />

    <Label HorizontalAlignment="Center" Content="abcdef" Width="200" Background="White" />

</Grid>


查看完整回答
反對 回復(fù) 2023-07-09
?
胡說叔叔

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超8個(gè)贊

在 DockPanel 中,HorizontalAlignment 僅當(dāng) DockPanel 的寬度大于其所有子項(xiàng)的總寬度時(shí)才有用。按鈕和標(biāo)簽的大小固定為 200 和 150,我相信 WPF 的行為將從左側(cè)剪切元素。


第一個(gè)棘手的方法是讓 DockPanel 填充兩列,當(dāng)網(wǎng)格變小時(shí),DockPanel 的一部分將進(jìn)入第一列的內(nèi)容下方,給人一種從左側(cè)剪切的感覺。


 <Grid>

     <Grid.ColumnDefinitions>

         <ColumnDefinition Width="*" MinWidth="60"/>

         <ColumnDefinition Width="*"/>

     </Grid.ColumnDefinitions>

     <DockPanel HorizontalAlignment="Right" Grid.ColumnSpan="2" LastChildFill="True">

         <Button Click="Button_Click" Content="click me 2" Width="150" DockPanel.Dock="Right" />

         <Label Content="abcdef 2" Width="200" />

         <Label x:Name="mLog" DockPanel.Dock="Right"/>

     </DockPanel>

     <Button Click="Button_Click" Content="click me 1" HorizontalContentAlignment="Stretch"/>

     <Label Content="abcdef 1" HorizontalContentAlignment="Stretch"/>

 </Grid>

另一種正確的方法是使用另一個(gè) Grid 而不是 DockPanel,確保我們讓第一列填充空間,以便與容器一起減小尺寸。


    <Grid HorizontalAlignment="Right" Grid.Column="1">

        <Grid.ColumnDefinitions>

            <ColumnDefinition Width="*"/>

            <ColumnDefinition Width="150"/>

        </Grid.ColumnDefinitions>

        <Button Click="Button_Click" Content="click me" Grid.Column="1" MinWidth="150"/>

        <Label Content="abcdef" Grid.Column="0"/>

        <Label x:Name="mLog"/>

    </Grid>


查看完整回答
反對 回復(fù) 2023-07-09
  • 3 回答
  • 0 關(guān)注
  • 171 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號