我想繪製從屏幕中心到左上邊緣的曲線。當窗口調整大小時,行應改變其座標。 是否有可能做到這一點尊重MVVM? 實施例: WPF - 從中心畫面繪製曲線到邊緣,隨着畫面變化動態調整
2
A
回答
2
注意,視框縮放其內容的呈現的輸出(包括例如Path
的StrokeThickness
),但不是圖的幾何形狀。
以下方法工作,而不縮放StrokeThickness
,因爲Ellipse
控制縮放其幾何形狀以適應其邊界:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border ClipToBounds="True">
<Ellipse Stroke="Black" StrokeThickness="1" RenderTransformOrigin="0,1">
<Ellipse.RenderTransform>
<ScaleTransform ScaleX="2" ScaleY="2"/>
</Ellipse.RenderTransform>
</Ellipse>
</Border>
</Grid>
2
兩者都具有1 *
的寬度要在第一列網格創建在窗口與2列的網格添加一個視框與StretchDirection =兩個和拉伸=填寫
在視圖框內添加曲線。
當窗口調整大小時,列將變小,並且視圖框將向下翻轉內容。
<Window x:Class="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:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Viewbox StretchDirection="Both" Stretch="Fill">
<Canvas Width="100" Height="200">
<Path Stroke="Black" StrokeThickness="3">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="0,0" IsClosed="False">
<ArcSegment Point="100,100" Size="100 100"/>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
</Canvas>
</Viewbox>
</Grid>
相關問題
- 1. 動畫繪製networkx邊緣
- 2. 沿着曲線繪製動畫圖像
- 3. 在畫布中繪製動畫曲線
- 4. 從弧形邊緣畫一條曲線
- 5. 從平面邊緣繪製線Unity
- 6. 安卓繪製動畫虛線曲線
- 7. 邊緣動畫時間線控制
- 8. WPF動畫啓動畫面
- 9. 繪製法線到曲面
- 10. 用綠色曲線繪製動畫
- 11. 變化畫面
- 12. 中畫面溢出邊緣(引導)
- 13. 從中心到邊緣的Android動畫阿爾法
- 14. WPF動畫 - 將畫布帶到前面
- 15. 繪製動畫線
- 16. 動畫的線,而在WPF繪製
- 17. 在Android畫布中繪製2D曲線?
- 18. 沿着二次曲線設置視圖的動畫中心點
- 19. 繪畫到面板
- 20. 如何使用畫布動畫繪製曲線?
- 21. 安卓繪製曲線路徑動畫畫布
- 22. 畫布:動畫貝塞爾曲線繪製
- 23. CSS3邊框繪製動畫
- 24. SVG動畫:從中心畫一條線
- 25. 邊緣動畫:動畫尺度錯誤
- 26. 如何在UWP中沿着Cubic Bezier曲線製作UserControl動畫
- 27. Android頁面捲曲動畫
- 28. 如何隨機化啓動畫面?
- 29. WPF在畫布面板背景上繪製彩色網格線
- 30. 在畫布上繪製曲線路徑?
我觀察到筆畫粗細的縮放。在一個WPF應用程序中,這個解決方案很不幸,當在一個UWP項目中使用相同的代碼時,邊界沒有ClipToBounds屬性,我所看到的對於模仿一條線而不是一半橢圓是至關重要的。 –
你已經用WPF標記了你的問題。無論如何,看到這裏:http://stackoverflow.com/q/13668236/1136211 – Clemens
我的錯誤,已標記爲更理想的答案 –