我在UserControl中定義了一個畫布,我想訪問GetLeft
靜態方法。問題是,這種方法需要靜態字段...我試圖做一個靜態構造函數,但沒有幫助...任何解決方案?我附上了下面的代碼。WPF Canvas無法訪問GetLeft方法(靜態方法)
<UserControl x:Class="DiagramDesigner.Resources.DesignerCanvas"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Canvas x:Name="CanvasX" Background="Transparent" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
代碼:
CanvasX.GetLeft(new DesignerItem());
錯誤:
Cannot acces static method 'GetLeft' in non static context