locked
Search Results (Search Contract)

    Question

  • Hi,

    I am trying to display some made up search results but , I cannot seem to get the title, subtitle and description to show up. ( 3 empty tiles does show up though)

    I am not sure If I am missing a concept or just making a silly mistake .... any help would be great!

    Inside

    Filter_SelectionChanged

    (void) sender;	// Unused parameter
    
    	// Determine what filter was selected
    	auto selectedFilter = (e->AddedItems->Size == 0) ? nullptr :
    		dynamic_cast<SearchResultsPageFilter^>(e->AddedItems->GetAt(0));
    	if (selectedFilter != nullptr)
    	{
    		// Mirror the results into the corresponding filter object to allow the
    		// RadioButton representation used when not snapped to reflect the change
    		selectedFilter->Active = true;
    
    		IVector<Object^>^ tmpR =(GetResults());
    		DefaultViewModel->Insert("Results", tmpR);
    		// TODO: Respond to the change in active filter by calling DefaultViewModel->Insert("Results", <value>)
    		//       where <value> is a collection of items with bindable Image, Title, Subtitle, and Description properties
    		
    		// Ensure results are found
    		IVector<Object^>^ resultsCollection;
    		if (this->DefaultViewModel->HasKey("Results") == true)
    		{
    			resultsCollection = dynamic_cast<IVector<Object^>^>(this->DefaultViewModel->Lookup("Results"));
    			if (resultsCollection != nullptr && resultsCollection->Size != 0)
    			{
    				VisualStateManager::GoToState(this, "ResultsFound", true);
    				return;
    			}
    		}
    	}
    
    	// Display informational text when there are no search results.
    	VisualStateManager::GoToState(this, "NoResultsFound", true);

    IVector<Object^>^ GetResults()
    {
    	Vector<Object^>^ rst = ref new Vector<Object^>();
    	zSearch::ResultItems^ it1 = ref new zSearch::ResultItems();
    	zSearch::ResultItems^ it2 = ref new zSearch::ResultItems();
    	zSearch::ResultItems^ it3 = ref new zSearch::ResultItems();
    
    	rst->Append(it1);
    	rst->Append(it2);
    	rst->Append(it3);
    	return rst;
    }

    Result Items

    namespace zSearch
    {
    	public ref class ResultItems sealed
    	{
    	public:
    
    	    property ImageSource^ Image 
                { 
                    ImageSource^ get() 
                    { 
                        return mImage; 
                    } 
                    void set(ImageSource^ value) 
                    { 
                        mImage = value; 
                    } 
                } 
    
    		 property String^ Title
    		{
    			String^ get() 
    			{ 
    				return mTitle; 
    			}
    
    			void set(String^ value) 
    			{ 
    				mTitle = value; 
    			}
    		}
    		property String^ Description
    		{
    			String^ get() 
    			{ 
    				return mDescription; 
    			}
    
    			void set(String^ value) 
    			{ 
    				mDescription = value; 
    			}
    		}
    		property String^ Subtitle
    		{
    			String^ get() 
    			{ 
    				return mSubtitle; 
    			}
    
    			void set(String^ value) 
    			{ 
    				mSubtitle = value; 
    			}
    		}
    	private:
    		String^ mTitle;
    		String^ mSubtitle;
    		String^ mDescription;
    		ImageSource^ mImage; 
    
    	public:
    		ResultItems(): mTitle("Title"),mSubtitle("Sub Title"), mDescription("Description")
    		{
    			SetImage("Assets/Logo.png");
    		}
    		void SetImage(Platform::String^ path) 
    		{ 
    			Windows::Foundation::Uri^ uri = ref new Windows::Foundation::Uri("ms-appx:///" + path);         
    			Image = ref new BitmapImage(uri); 
    		} 
    
    	};
    };

    Wednesday, March 27, 2013 6:02 PM

Answers

  • forgot

    [Windows::UI::Xaml::Data::Bindable]

    for the class! .....

    • Marked as answer by zCDev Thursday, March 28, 2013 4:57 PM
    Thursday, March 28, 2013 4:57 PM

All replies