locked
BindingExpression RRS feed

  • Question

  • i try to write windows phone application using c++/cx , however i meet a big problem,it cost me a lot of time,I don't how to write Binding using c++/cx and there always throw BindingExpression. someone can help me?

    	public ref class Message sealed {
    	public:
    		Message(Platform::String^ t_title):_title(t_title){}
    		property Platform::String^ myTitles {
    			void set(Platform::String^ t_title) {
    				_title = t_title;
    			}
    
    			Platform::String^ get() {
    				return _title;
    			}
    		}
    	private:
    		Platform::String^ _title;
    	};
    MainPage::MainPage()
    {
    	InitializeComponent();
    	msg_obj = ref new Message("Hello World");
    	OutputDebugString(L"MSG_OBJ Text: ");
    	OutputDebugString(msg_obj->myTitles->Data());
    	
    	this->DataContext = msg_obj;
    }
        <Grid Name="myGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <TextBlock Height="40" DoubleTapped="myTitle_DoubleTapped" FontSize="32" Name="BindingTitle" Text="{Binding myTitles}" Width="400" Foreground="#FF380B0B"/>
        </Grid>

    Error Information:

    Error: BindingExpression path error: 'myTitles' property not found on 'BindTest.Message'. BindingExpression: Path='myTitles' DataItem='BindTest.Message'; target element is 'Windows.UI.Xaml.Controls.TextBlock' (Name='BindingTitle'); target property is 'Text' (type 'String')



    Tuesday, March 8, 2016 7:21 AM

All replies