直接上Blend设计代码:
<GrID x:name="Tab1" margin="0,10,0" HorizontalAlignment="Right" VerticalAlignment="top"> <GrID.ColumnDeFinitions> <ColumnDeFinition WIDth="32" x:name="grIDTab1" /> <ColumnDeFinition WIDth="240" x:name="grIDTab2"/> </GrID.ColumnDeFinitions> <GrID GrID.Column="0" margin="0" HorizontalAlignment="Right" WIDth="32" Height="196" MouseleftbuttonDown="grIDTab1_MouseleftbuttonDown" MouseleftbuttonUp="grIDTab1_MouseleftbuttonUp" VerticalAlignment="top"> <Path Data="M14.499997,0.5 L30.5,195.5092 C22.749666,179.34477 21.416317,172.5116 12.74966,165.34474 C10.101785,163.15511 0.50000095,159.98717 0.5,153.17583 L0.5,12.833001 C0.50000095,6.0216737 6.0216732,0.50000131 12.833001,0.50000149 z" margin="0,1,0" Stretch="Fill" stroke="#FF97B0CB" UseLayoutRounding="False"> <Path.Fill> <linearGradIEntBrush EndPoint="0.904,0.386" StartPoint="0.114,0.385"> <GradIEntStop color="#FFD7DCE1" Offset="0.383"/> <GradIEntStop color="#FFFDFDFE" Offset="1"/> <GradIEntStop color="#FFDFE3E7"/> </linearGradIEntBrush> </Path.Fill> </Path> <Rectangle strokeThickness="0.5" RadiusY="3" RadiusX="3" stroke="#FF319CE1" Height="20" margin="7,13,5,0" VerticalAlignment="top" Fill="#FFFBFdfc"> <Rectangle.OpacityMask> <ImageBrush Stretch="Fill"/> </Rectangle.OpacityMask> </Rectangle> <Rectangle strokeThickness="0.5" margin="6,3,0" Height="23" VerticalAlignment="top"> <Rectangle.Fill> <ImageBrush ImageSource="Images/ztfx1.png"/> </Rectangle.Fill> <Rectangle.OpacityMask> <ImageBrush Stretch="Fill"/> </Rectangle.OpacityMask> </Rectangle> <TextBlock margin="1,40,0" textwrapPing="Wrap" TextAlignment="Center" FontSize="16" lineHeight="21.333" Text="专题分析" VerticalAlignment="top"/> <TextBlock x:name="tbTip1" margin="1,38" textwrapPing="Wrap" TextAlignment="Center" FontSize="16" VerticalAlignment="Bottom" Text="<<" Foreground="#FF0033FF"/> </GrID> <GrID GrID.Column="1" margin="0" WIDth="240" Height="249" HorizontalAlignment="Right" VerticalAlignment="top"> <Rectangle margin="0,25,0" Fill="White" stroke="#FF97B0CB" HorizontalAlignment="Right" WIDth="240"/> <Rectangle Height="35" VerticalAlignment="top"> <Rectangle.stroke> <linearGradIEntBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradIEntStop color="#FFD6DEEA"/> <GradIEntStop color="#FF97B0CB" Offset="0.526"/> </linearGradIEntBrush> </Rectangle.stroke> <Rectangle.Fill> <linearGradIEntBrush EndPoint="0.5,0"> <GradIEntStop color="#FFF3F6FB" Offset="0"/> <GradIEntStop color="#FFACC8E7" Offset="1"/> <GradIEntStop color="#FFC3D6ED" Offset="0.513"/> </linearGradIEntBrush> </Rectangle.Fill> </Rectangle> <StackPanel margin="0,36,7,0" VerticalAlignment="top" HorizontalAlignment="Right" WIDth="230"> <GrID Height="40" d:LayoutOverrIDes="Height" VerticalAlignment="top" WIDth="230"> <sdk:DatePicker x:name="dpStart" margin="48,6,67,6" WIDth="115"/> <ComboBox x:name="cbStart" HorizontalAlignment="Right" margin="0,16,6" WIDth="49"/> <TextBlock HorizontalAlignment="left" margin="3,0" textwrapPing="Wrap" Text="起始:" WIDth="56" FontSize="16" FontFamily="Microsoft YaHei" VerticalAlignment="Center"/> <TextBlock textwrapPing="Wrap" Text="时" FontSize="16" FontFamily="Microsoft YaHei" VerticalAlignment="Center" HorizontalAlignment="Right" WIDth="15" margin="0,-1,0"/> </GrID> <GrID Height="40" d:LayoutOverrIDes="Height,Verticalmargin" WIDth="230"> <sdk:DatePicker x:name="dpEnd" margin="48,6" WIDth="115"/> <ComboBox x:name="cbEnd" HorizontalAlignment="Right" margin="0,0" textwrapPing="Wrap" Text="截至:" WIDth="56" FontSize="16" FontFamily="Microsoft YaHei" VerticalAlignment="Center"/> <TextBlock textwrapPing="Wrap" Text="时" FontSize="16" FontFamily="Microsoft YaHei" VerticalAlignment="Center" HorizontalAlignment="Right" WIDth="15" margin="0,Verticalmargin" WIDth="230"> <ComboBox x:name="cbRainGrade" margin="78,6"/> <TextBlock HorizontalAlignment="left" margin="4,0" textwrapPing="Wrap" Text="雨量级别:" WIDth="80" FontSize="16" FontFamily="Microsoft YaHei" VerticalAlignment="Center"/> </GrID> <GrID Height="40" d:LayoutOverrIDes="Height,Verticalmargin" Visibility="Collapsed"> <Radiobutton x:name="rb1" Content="稀" margin="70,11,1" FontSize="13.333" FontFamily="Microsoft YaHei" Groupname="rbGroup" IsChecked="True" Cursor="Hand" Click="rb_Click"/> <TextBlock HorizontalAlignment="left" margin="4,0" textwrapPing="Wrap" Text="过滤级:" WIDth="55" FontSize="13.333" FontFamily="Microsoft YaHei" VerticalAlignment="Center"/> <Radiobutton x:name="rb2" Content="密" margin="0,12,8,0" FontSize="13.333" FontFamily="Microsoft YaHei" HorizontalAlignment="Right" WIDth="55" Groupname="rbGroup" Cursor="Hand" Click="rb_Click"/> </GrID> <GrID Height="40" d:LayoutOverrIDes="Height,Verticalmargin"> <button x:name="btnAnalysis" Content="雨量等值线" margin="66,61,0" VerticalAlignment="Center" Cursor="Hand" FontSize="16" FontFamily="Microsoft YaHei" d:LayoutOverrIDes="WIDth" Click="btnAnalysis_Click"/> </GrID> <GrID Height="40" d:LayoutOverrIDes="Height,Verticalmargin"> <button x:name="btnStatistic" Content="雨量统计" margin="66,0" VerticalAlignment="Center" Cursor="Hand" FontSize="16" FontFamily="Microsoft YaHei" d:LayoutOverrIDes="WIDth" Click="btnStatistic_Click"/> </GrID> </StackPanel> <TextBlock margin="30,37,217" textwrapPing="Wrap" FontSize="21.333" FontFamily="微软雅黑" TextAlignment="Center" Text="专题分析"/> </GrID> </GrID> <GrID x:name="Tab2" margin="0,273,0" HorizontalAlignment="Right" VerticalAlignment="top"> <GrID.ColumnDeFinitions> <ColumnDeFinition WIDth="32" x:name="grIDTab11" /> <ColumnDeFinition WIDth="240" x:name="grIDTab21"/> </GrID.ColumnDeFinitions> <GrID GrID.Column="0" margin="0" Height="153" HorizontalAlignment="Right" WIDth="32" MouseleftbuttonDown="grIDTab11_MouseleftbuttonDown" MouseleftbuttonUp="grIDTab11_MouseleftbuttonUp" VerticalAlignment="top"> <Path Data="M14.499997,152.50117 C22.749666,136.33675 21.416317,129.50357 12.74966,122.33672 C10.101785,120.14707 0.50000095,116.97913 0.5,110.1678 L0.5,0.006" Stretch="Fill" stroke="#FF97B0CB" UseLayoutRounding="False"> <Path.Fill> <linearGradIEntBrush EndPoint="0.904,0.385"> <GradIEntStop color="#FFD7DCE1" Offset="0.383"/> <GradIEntStop color="#FFFDFDFE" Offset="1"/> <GradIEntStop color="#FFDFE3E7"/> </linearGradIEntBrush> </Path.Fill> </Path> <TextBlock margin="1,65" textwrapPing="Wrap" TextAlignment="Center" FontSize="16" lineHeight="21.333" Text="图 例"/> <GrID Height="20" margin="7,0" VerticalAlignment="top"> <Rectangle strokeThickness="0.5" RadiusX="2" RadiusY="2" stroke="#FF319CE1"> <Rectangle.Fill> <linearGradIEntBrush EndPoint="0.5,0"> <GradIEntStop color="#FFF1F1F1" Offset="0"/> <GradIEntStop color="#FFD0D0D0" Offset="1"/> <GradIEntStop color="#FFDEDEDE" Offset="0.448"/> <GradIEntStop color="#FFD0D0D0" Offset="0.5"/> </linearGradIEntBrush> </Rectangle.Fill> </Rectangle> <Ellipse Fill="#FF1016FF" HorizontalAlignment="left" Height="3" margin="2,2,0" VerticalAlignment="top" WIDth="3" strokeThickness="0.2"/> <Ellipse Fill="#FFFF871C" HorizontalAlignment="left" margin="2,9" WIDth="3" strokeThickness="0.2"/> <Ellipse Fill="#FFE8343B" HorizontalAlignment="left" Height="3" margin="2,3" VerticalAlignment="Bottom" WIDth="3" strokeThickness="0.2"/> <Path Data="M262.75,109 L269.91666,109" Height="2" margin="6,2.6,0" Stretch="Fill" stroke="#FF1016FF" UseLayoutRounding="False" VerticalAlignment="top" strokeThickness="2"> <Path.Fill> <linearGradIEntBrush EndPoint="0.5,0"> <GradIEntStop color="#FFF1F1F1" Offset="0"/> <GradIEntStop color="#FFD0D0D0" Offset="1"/> <GradIEntStop color="#FFDEDEDE" Offset="0.448"/> <GradIEntStop color="#FFE8343B" Offset="0.5"/> </linearGradIEntBrush> </Path.Fill> </Path> <Path Data="M262.75,109" margin="6,8.562,9.438" Stretch="Fill" stroke="#FFFF871C" UseLayoutRounding="False" strokeThickness="2"> <Path.Fill> <linearGradIEntBrush EndPoint="0.5,3.309" Stretch="Fill" stroke="#FFE8343B" UseLayoutRounding="False" VerticalAlignment="Bottom" strokeThickness="2"> <Path.Fill> <linearGradIEntBrush EndPoint="0.5,0"> <GradIEntStop color="White" Offset="0.023"/> <GradIEntStop color="#FFE93940" Offset="0.046"/> </linearGradIEntBrush> </Path.Fill> </Path> </GrID> <TextBlock x:name="tbTip2" margin="1,38" textwrapPing="Wrap" TextAlignment="Center" FontSize="16" VerticalAlignment="Bottom" Text="<<" Foreground="#FF0033FF"/> </GrID> <GrID GrID.Column="1" margin="0" WIDth="240" Height="204" HorizontalAlignment="Right" VerticalAlignment="top"> <Rectangle HorizontalAlignment="Right" WIDth="240" Height="35" VerticalAlignment="top"> <Rectangle.stroke> <linearGradIEntBrush EndPoint="0.5,0"> <GradIEntStop color="#FFF3F6FB" Offset="0"/> <GradIEntStop color="#FFACC8E7" Offset="1"/> <GradIEntStop color="#FFC3D6ED" Offset="0.513"/> </linearGradIEntBrush> </Rectangle.Fill> </Rectangle> <Rectangle margin="0,30,0" Fill="White" stroke="#FF97B0CB" HorizontalAlignment="Right" WIDth="240"/> <Path Data="M304.5,131 L304.5,260.81238" margin="123.5,30.5,1.099" Stretch="Fill" UseLayoutRounding="False" Fill="#FF97B0CB" stroke="#FF97B0CB" WIDth="2" HorizontalAlignment="left" d:LayoutOverrIDes="WIDth"/> <Path Data="M220,157.5 L390.00662,157.5" Height="2" margin="0,67.811,0.496,0" Stretch="Fill" UseLayoutRounding="False" VerticalAlignment="top" Fill="Black" stroke="#FF97B0CB" HorizontalAlignment="Right" WIDth="239"/> <Path Data="M220,88.694" Stretch="Fill" UseLayoutRounding="False" VerticalAlignment="Bottom" Fill="Black" stroke="#FF97B0CB" HorizontalAlignment="Right" WIDth="239"/> <Path Data="M220,43.199" Stretch="Fill" UseLayoutRounding="False" VerticalAlignment="Bottom" Fill="Black" stroke="#FF97B0CB" HorizontalAlignment="Right" WIDth="239"/> <Ellipse Fill="#FF3FC916" HorizontalAlignment="left" Height="11" margin="7,42,0" VerticalAlignment="top" WIDth="11"/> <Ellipse Fill="#FFFFEB00" HorizontalAlignment="left" margin="7,85,0" WIDth="11" Height="11" VerticalAlignment="top"/> <Ellipse Fill="#FFEC26A5" HorizontalAlignment="left" margin="7,61" WIDth="11" Height="11" VerticalAlignment="Bottom"/> <Ellipse Fill="#FF888489" HorizontalAlignment="left" margin="7,17" WIDth="11" Height="11" VerticalAlignment="Bottom"/> <Ellipse Fill="#FF1016FF" HorizontalAlignment="Right" Height="11" margin="0,93,0" VerticalAlignment="top" WIDth="11" d:LayoutOverrIDes="HorizontalAlignment"/> <Ellipse Fill="#FFFF871C" HorizontalAlignment="Right" margin="0,0" WIDth="11" Height="11" VerticalAlignment="top" d:LayoutOverrIDes="HorizontalAlignment"/> <Ellipse Fill="#FFE8343B" HorizontalAlignment="Right" margin="0,61" WIDth="11" Height="11" VerticalAlignment="Bottom" d:LayoutOverrIDes="HorizontalAlignment"/> <TextBlock margin="37,172" textwrapPing="Wrap" FontSize="21.333" FontFamily="微软雅黑" TextAlignment="Center"><Run Text="图"/><Run Text=" "/><Run Text=" 例"/></TextBlock> <TextBlock HorizontalAlignment="left" margin="22,0" textwrapPing="Wrap" Text="<10" WIDth="70" FontSize="16" Height="19" VerticalAlignment="top" d:LayoutOverrIDes="HorizontalAlignment"/> <TextBlock HorizontalAlignment="left" margin="22,79,0" textwrapPing="Wrap" Text="25~50" WIDth="70" FontSize="16" Height="19" VerticalAlignment="top" d:LayoutOverrIDes="HorizontalAlignment"/> <TextBlock HorizontalAlignment="left" margin="22,59" textwrapPing="Wrap" WIDth="70" Height="19" VerticalAlignment="Bottom" FontSize="16" d:LayoutOverrIDes="HorizontalAlignment"><Run Text="100"/><Run Text="~"/><Run Text="20"/><Run Text="0"/></TextBlock> <TextBlock HorizontalAlignment="left" margin="22,13" textwrapPing="Wrap" WIDth="72" Height="19" VerticalAlignment="Bottom" Text="没有数据" FontSize="16"/> <TextBlock HorizontalAlignment="Right" margin="0,19,0" textwrapPing="Wrap" Text="10~25" WIDth="70" FontSize="16" Height="19" VerticalAlignment="top"/> <TextBlock HorizontalAlignment="Right" margin="0,0" textwrapPing="Wrap" WIDth="70" FontSize="16" Height="19" VerticalAlignment="top"><Run Text="50"/><Run Text="~100"/></TextBlock> <TextBlock HorizontalAlignment="Right" margin="0,59" textwrapPing="Wrap" WIDth="70" Height="19" VerticalAlignment="Bottom" FontSize="16"><Run Text=">="/><Run Text="20"/><Run Text="0"/></TextBlock> </GrID> </GrID>
private voID grIDTab1_MouseleftbuttonDown(object sender,System.windows.input.MousebuttonEventArgs e){ e.Handled = true;}private voID grIDTab1_MouseleftbuttonUp(object sender,System.windows.input.MousebuttonEventArgs e){ if (this.grIDTab2.WIDth == new GrIDLength(240,GrIDUnitType.Pixel)) { //处于展开状态 this.tbTip1.Text = "<<"; GrID.SetColumnSpan(this.Tab1,1); this.grIDTab2.WIDth = new GrIDLength(0,GrIDUnitType.Pixel); } else { //处于收缩状态 this.tbTip1.Text = ">>"; GrID.SetColumnSpan(this.Tab1,2); this.grIDTab2.WIDth = new GrIDLength(240,GrIDUnitType.Pixel); }}private voID grIDTab11_MouseleftbuttonDown(object sender,System.windows.input.MousebuttonEventArgs e){ e.Handled = true;}private voID grIDTab11_MouseleftbuttonUp(object sender,System.windows.input.MousebuttonEventArgs e){ if (this.grIDTab21.WIDth == new GrIDLength(240,GrIDUnitType.Pixel)) { //处于展开状态 this.tbTip2.Text = "<<"; GrID.SetColumnSpan(this.Tab2,1); this.grIDTab21.WIDth = new GrIDLength(0,GrIDUnitType.Pixel); } else { //处于收缩状态 this.tbTip2.Text = ">>"; GrID.SetColumnSpan(this.Tab2,2); this.grIDTab21.WIDth = new GrIDLength(240,GrIDUnitType.Pixel); }}
点击Tab即可收缩,如右图 总结
以上是内存溢出为你收集整理的Silverlight中利用Blend绘制可伸缩的Tab菜单全部内容,希望文章能够帮你解决Silverlight中利用Blend绘制可伸缩的Tab菜单所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)