2015-09-14 64 views
1

我嘗試將模型綁定到xml.I在wpf中是如此新穎。但是ı不能使用這種語法。它給出了錯誤。它是「本地成員不被識別或不可訪問」wpf綁定的種類

<Grid local:GridHelpers.RowCount="{Binding RowCount}" 
     local:GridHelpers.ColumnCount="{Binding ColumnCount}" /> 

如何轉換此語法。這是xaml

我試試這個,但這不行。

<Grid> 
    <ContentPresenter 
      Name="--" 
      Content="{Binding ElementName=RowCount, Path=?}"> 
    </ContentPresenter> 
</Grid> 

我Xmal位級相同的例子:https://rachel53461.wordpress.com/2011/09/17/wpf-grids-rowcolumn-count-properties/

+1

你能解釋一下什麼是你想達到什麼目的? – Muds

+0

ı嘗試綁定ı看看這個例子。但是這個綁定不適用於我https://rachel53461.wordpress.com/2011/09/17/wpf-grids-rowcolumn-count-properties/ – user2583040

+0

你添加了本地作爲xmlns嗎?在你的xaml中? – Muds

回答

0

您需要GridHelper類添加到您的項目和命名空間添加到您的XAML文件,那麼你可以參考它。

截至目前它抱怨編譯器無法理解什麼是本地命名空間。

+0

項目有GridHelper類。 – user2583040

+0

是在xaml中添加的這個類的命名空間?粘貼你的整個xaml – Muds

+0

是的,它是。我看這個例子。我的班級幾乎與[鏈接]相同(https://rachel53461.wordpress.com/2011/09/17/wpf-grids-rowcolumn-count-properties/) – user2583040

0

添加XML命名空間聲明最頂端的元素(如窗口或用戶控件)

xmlns:local="clr-namespace:WpfApplication1" 

只是GridHelper類的命名空間替換WpfApplication1:

namespace WpfApplication1 
{ 
    public class GridHelper... 
} 
+0

我試過這個,但它不工作.. –