tôi muốn di chuyển tất cả nội dung của lưới sang kiểu/mẫu/Vùng chứa (không biết chọn kiểu nào ...), nhưng tôi đã cố chuyển nó thành kiểu.không có thuộc tính mẫu nào trên kiểu lưới trong WPF?
nhưng vấn đề là tôi gặp lỗi: "Không thể tìm thấy Mẫu thuộc tính kiểu 'trên loại' System.Windows.Controls.Grid '".
tôi biết không có thuộc tính mẫu cho lưới, nhưng tôi sẽ di chuyển nội dung lưới vào tệp ResourceDirectory bằng cách nào khác?
Đây là mã Lưới:
<Grid Grid.Column="0" Grid.Row="0" Margin="10,15,5,5" >
<Border BorderThickness="7" CornerRadius="4">
<Border.BorderBrush>
<SolidColorBrush Color="#73B2F5" Opacity="0.5"/>
</Border.BorderBrush>
<Grid>
<Grid.Background>
<SolidColorBrush Color="#73B2F5" Opacity="0.5"/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Button Name="CustomerButton" Grid.Row="1" Grid.Column="0" Width="40" Height="40" Content="Customer" Click="CustTabButton_Click" ></Button>
<Button Name="BossButton" Grid.Row="1" Width="40" Height="40" Content="Boss" Margin="23,206,23,114" Click="BossTabButton_Click"></Button>
</Grid>
</Border>
</Grid>
Đây là mã trong resourceDirectory sau khi tôi di chuyển mã có:
<Style x:Key="LeftSidePanel" TargetType="{x:Type Grid}">
<Setter Property="Margin" Value="10,15,5,5" />
<Setter Property="Template">
<Setter.Value>
<Border BorderThickness="7" CornerRadius="4">
<Border.BorderBrush>
<SolidColorBrush Color="#73B2F5" Opacity="0.5"/>
</Border.BorderBrush>
<Grid>
<Grid.Background>
<SolidColorBrush Color="#73B2F5" Opacity="0.5"/>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Button Name="CustomerButton" Grid.Row="1" Grid.Column="0" Width="40" Height="40" Content="Customer" Click="CustTabButton_Click"></Button>
<Button Name="BossButton" Grid.Row="1" Width="40" Height="40" Content="Boss" Margin="23,206,23,114" Click="BossTabButton_Click"></Button>
</Grid>
</Border>
</Setter.Value>
</Setter>
</Style>
tôi đã bỏ lỡ gì?
Điều này là tốt nhưng Grid.Column và Grid.Row không có ảnh hưởng ở đây. Họ nên cư trú trên kiểm soát nội dung. – Asheh