http://www.axelerate.com/SilverlightSamples/Silverlight3D/
Is good one i got the source code from Code Plex . then i will apply the image from Xaml page it was applied.
But when i am going to apply the image from code behind it cant work in here i am posting my code
From Xaml
<axmedia3d:GeometryModel3D.Material>
<axmedia3d:DiffuseMaterial x:Name="dmat" >
<axmedia3d:DiffuseMaterial.Brush>
<ImageBrush x:Name="myImageBrush"/>
</axmedia3d:DiffuseMaterial.Brush>
</axmedia3d:DiffuseMaterial>
From Code Behind
BitmapImage bitmapImage = new BitmapImage(new Uri("Pat.jpg", UriKind.Relative));
myImageBrush.ImageSource = bitmapImage;
dmat.Brush = myImageBrush;
but when i am executing it cause error Object reference not set to an instance of an object
How can i apply the image from code behind
But
Image path is correct ..
for example
Xaml page
<Button x:Name="MYbTN" Height="50" Width="50" Click="MYbTN_Click" >
<Button.Background>
<ImageBrush x:Name="myBrush" ImageSource="Shirt Pattern.jpg" ></ImageBrush>
</Button.Background>
</Button>
Code Behind
private void MYbTN_Click(object sender, RoutedEventArgs e)
{
myBrush.ImageSource = new BitmapImage(new Uri("Pat.jpg", UriKind.Relative));
}
its working fine .. Image will be changed
but i want to change image through code behind
<axmedia3d:GeometryModel3D.Material>
<axmedia3d:DiffuseMaterial x:Name="dmat" >
<axmedia3d:DiffuseMaterial.Brush>
<ImageBrush x:Name="myImageBrush"/>
</axmedia3d:DiffuseMaterial.Brush>
</axmedia3d:DiffuseMaterial>
it was not working ..