سلام بر برنامه نویسان عزیز 😉 در این مطلب از وب سایت پروگرم 98 کد ساخت یک جدول با استفاده از چندین Line با wpf و سی شارپ را آماده کردم. انشاالله که این کد سی شارپ براتون مفید باشد.
تصویر خروجی این کد:
کد ساخت یک جدول با استفاده از چندین Line با wpf و سی شارپ :
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas.Resources>
<Style x:Key="base" TargetType="Line">
<Setter Property="Stroke" Value="Blue" />
</Style>
<Style x:Key="horz" TargetType="Line"
BasedOn="{StaticResource base}">
<Setter Property="X1" Value="100" />
<Setter Property="X2" Value="300" />
<Setter Property="Y2" Value="{Binding RelativeSource={RelativeSource self}, Path=Y1}" />
</Style>
<Style x:Key="vert" TargetType="Line" BasedOn="{StaticResource base}">
<Setter Property="Y1" Value="100" />
<Setter Property="Y2" Value="300" />
<Setter Property="X2" Value="{Binding RelativeSource={RelativeSource self}, Path=X1}" />
</Style>
</Canvas.Resources>
<Line Style="{StaticResource horz}" Y1="100" />
<Line Style="{StaticResource horz}" Y1="125" />
<Line Style="{StaticResource horz}" Y1="150" />
<Line Style="{StaticResource horz}" Y1="175" />
<Line Style="{StaticResource horz}" Y1="200" />
<Line Style="{StaticResource horz}" Y1="225" />
<Line Style="{StaticResource horz}" Y1="250" />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas.Resources>
<Style x:Key="base" TargetType="Line">
<Setter Property="Stroke" Value="Blue" />
</Style>
<Style x:Key="horz" TargetType="Line"
BasedOn="{StaticResource base}">
<Setter Property="X1" Value="100" />
<Setter Property="X2" Value="300" />
<Setter Property="Y2" Value="{Binding RelativeSource={RelativeSource self}, Path=Y1}" />
</Style>
<Style x:Key="vert" TargetType="Line" BasedOn="{StaticResource base}">
<Setter Property="Y1" Value="100" />
<Setter Property="Y2" Value="300" />
<Setter Property="X2" Value="{Binding RelativeSource={RelativeSource self}, Path=X1}" />
</Style>
</Canvas.Resources>
<Line Style="{StaticResource horz}" Y1="100" />
<Line Style="{StaticResource horz}" Y1="125" />
<Line Style="{StaticResource horz}" Y1="150" />
<Line Style="{StaticResource horz}" Y1="175" />
<Line Style="{StaticResource horz}" Y1="200" />
<Line Style="{StaticResource horz}" Y1="225" />
<Line Style="{StaticResource horz}" Y1="250" />