Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have user control like below:
<usercontrol>
x:Class="ScoreCardInMVVM.Common.ImageButtonControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ScoreCardInMVVM.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:am="using:ScoreCardInMVVM.Model"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<usercontrol.resources>
<local:heightconverter x:key="HeightConverter" xmlns:x="#unknown" xmlns:local="#unknown">

<usercontrol.datacontext>
<am:imagebuttoncontrolmodel xmlns:am="#unknown">

<stackpanel height="{Binding Path=ActualHeight,ElementName=UserControl1}">
Width="{Binding Path=ActualWidth,ElementName=UserControl1}"
removed="{Binding Path=BackGroundColor}"
Orientation="Vertical">
<!--<textblock text="{Binding Path=ImageText}" margin="0,4,0,0">
FontSize="20" HorizontalAlignment="Center" VerticalAlignment="Center"/>-->
<Image Stretch="Fill"
Source="{Binding ImageSourcePath}"/>



Class As below:

class ImageButtonControlModel
{
public string ImageText { get; set; }
public string ImageSourcePath { get; set; }
public string BackGroundColor { get; set; }
public string ContentFontFamily { get; set; }
}

Inside page I have 2 instances of user controls like below:
imagebuttoncontrol x:name="tileDev0" grid.row="3" grid.column="1" xmlns:x="#unknown" xmlns:uc="#unknown" />
imagebuttoncontrol x:name="tileDev1" grid.row="3" grid.column="1" xmlns:x="#unknown" xmlns:uc="#unknown" />

I have view model for page like below:
C#
class MainPageViewModel
   {
       private ImageButtonControlModel ImageButtonControlModelObj = new ImageButtonControlModel();

       public string txtImageText
       {
           get { return "Delivery"; }
           set { ImageButtonControlModelObj.ImageText = "Delivery"; }
       }

       public string txtImageSourcePath
       {
           get { return "/Assets/Delivery.png"; }
           set { ImageButtonControlModelObj.ImageSourcePath="/Assets/Delivery.png"; }
       }

        public string txtBackGroundColor
       {
           get { return ImageButtonControlModelObj.BackGroundColor ; }
           set {  ImageButtonControlModelObj.BackGroundColor= "Blue"; }
       }

       public string txtContentFontFamily
       {
           get { return "Arial"; }
           set {ImageButtonControlModelObj.ContentFontFamily= "Arial" ; }
       }






How to bind 2 different images to user control tileDev0 & tileDev1 through view model , (I have viewmodel of a page through which I am trying to bind data to this user controls)
Posted
Updated 17-Dec-14 22:38pm
v2

1 solution

pls somebody ans above quesiton
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900