Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6158637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:59:29+00:00 2026-05-23T20:59:29+00:00

My xaml code is below; <Page x:Class=Ab3d.PowerToys.Samples.Objects3D.Model3DFactorySample xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:cameras=clr-namespace:Ab3d.Cameras;assembly=Ab3d.PowerToys xmlns:ab3d=clr-namespace:Ab3d.Controls;assembly=Ab3d.PowerToys xmlns:visuals=clr-namespace:Ab3d.Visuals;assembly=Ab3d.PowerToys Title=AllModelsSample MinWidth=600>

  • 0

My xaml code is below;

<Page x:Class="Ab3d.PowerToys.Samples.Objects3D.Model3DFactorySample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cameras="clr-namespace:Ab3d.Cameras;assembly=Ab3d.PowerToys"
    xmlns:ab3d="clr-namespace:Ab3d.Controls;assembly=Ab3d.PowerToys"  
    xmlns:visuals="clr-namespace:Ab3d.Visuals;assembly=Ab3d.PowerToys"        
    Title="AllModelsSample"
    MinWidth="600">
    <Page.Resources>
        <DiffuseMaterial x:Key="ObjectsMaterial" Brush="#247589"/>
    </Page.Resources>
    <Grid Name="MainGrid">
        <Grid.Background>
            <LinearGradientBrush StartPoint="0 0" EndPoint="0 1">
                <GradientStop Offset="0" Color="#033C62"/>
                <GradientStop Offset="1" Color="#01131F"/>
            </LinearGradientBrush>
        </Grid.Background>
        <Viewport3D Name="MainViewport">
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <Model3DGroup x:Name="MainModel3DGroup"/>
                </ModelVisual3D.Content>
            </ModelVisual3D>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <Model3DGroup>
                        <AmbientLight Color="#333333"/>
                    </Model3DGroup>
                </ModelVisual3D.Content>
            </ModelVisual3D>
        </Viewport3D>

        <cameras:SceneCamera Name="Camera1" Heading="30" Attitude="-10" Bank="0" Distance="10" ShowCameraLight="Always"/>

        <!-- EventsSourceElement is set to MainGrid - this means that the MainGrid's mouse events are subscribed to - this enables camera rotation without the need to be over the rendered 3D element -->
        <ab3d:MouseCameraController Name="MouseCameraController1" UsedMouseButton="Left" EventsSourceElement="{Binding ElementName=MainGrid}"/>
        <ab3d:CameraControlPanel VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="5" Width="150" Height="75"/>
        <Viewport3D x:Name="ViewPort" Margin="0,-10,0,0" KeyDown="Window_KeyDown">
            <Viewport3D.Camera>
                <PerspectiveCamera x:Name="anakamera" FieldOfView="90" 
                                           Position="0.4,7,7.5" 
                                           LookDirection="0,-0.5,-1"  
                                            />
            </Viewport3D.Camera>
        </Viewport3D>
        <TextBlock FontWeight="Bold" FontSize="20" Foreground="Silver" Margin="10" VerticalAlignment="Top" HorizontalAlignment="Left" Text="3D objects created from code with Ab3d.Models.Model3DFactory"/>
    </Grid>
</Page>

And my xaml.cs code is below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Media3D;

namespace Ab3d.PowerToys.Samples.Objects3D
{
    /// <summary>
    /// Interaction logic for Model3DFactorySample.xaml
    /// </summary>
    public partial class Model3DFactorySample : Page
    {

        public Model3DFactorySample()
        {
            InitializeComponent();

            CreateModels();
        }

        ContainerUIElement3D barsContainer = new ContainerUIElement3D();
        mamuller mamuller = new mamuller();
        yuzeyler yuzeyler = new yuzeyler();
        public static ModelUIElement3D modelOlustur(
           Double x,
          Double y,
          Double z,
          Double boy,
          Double sag,
          Double sol,
          MeshGeometry3D mesh, Brush brush)
        {
            //Ab3d.Common.EventManager3D
            ModelUIElement3D modelUIElement3D = new ModelUIElement3D()
            {
                Model = new GeometryModel3D(mesh, new DiffuseMaterial(brush))
            };

            Transform3DGroup transform = new Transform3DGroup();

            //ScaleY is ranged between 0.0 : 1.0, for 0% to 100%
            transform.Children.Add(new ScaleTransform3D(sol, sag, boy));//boyutlar x sol y sag z uzunlk

            transform.Children.Add(
                new TranslateTransform3D(x, y, z));///lokasyonları belırlenıyor x sag sol y asagı yukarı z derınlık
            modelUIElement3D.Transform = transform;
            return modelUIElement3D;

        }
        private void CreateModels()
        {
            Material material;

            material = this.FindResource("ObjectsMaterial") as Material;


            Brush renk = Brushes.Red;
            ModelUIElement3D firin = modelOlustur(8.5, 1.6, -2.7, 0.1, 0.1, 0.1, (MeshGeometry3D)yuzeyler.Resources["fırın"], Brushes.Gray);
            ModelUIElement3D sogutmaplt = modelOlustur(-7.6, 0.4, -2.7, 0.1, 0.1, 0.1, (MeshGeometry3D)yuzeyler.Resources["sogutmaplatformu"], Brushes.Gray);
            ModelUIElement3D bar2 = modelOlustur(1, 2, 1, 0.1, 0.1, 0.1, (MeshGeometry3D)mamuller.Resources["12metreKOS-D"], renk);
            ModelUIElement3D bar3 = modelOlustur(1, 2.077, 1, 0.1, 0.1, 0.1, (MeshGeometry3D)mamuller.Resources["12metreKOS-D"], Brushes.Yellow);


            barsContainer.Children.Add(firin);
            barsContainer.Children.Add(sogutmaplt);

            barsContainer.Children.Add(bar2);
            barsContainer.Children.Add(bar3);

            //barsContainer.Children.Add(sogutmaplt);
            //ViewPort.Children.Add(barsContainer);
            MainViewport.Children.Add(barsContainer);
            //string yon = "12metreKOS-D";



        }


        #region klavye mouse işlmleri

        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.N)
            {
                anakamera.Position = new Point3D(0.4, 7, 7.5);
                anakamera.LookDirection = new Vector3D(0, -0.5, -1);
            }

            #region normal kamera ayarları
            if (e.Key == Key.Left)
            {
                RotateTransform3D cameraspin = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 10));
                cameraspin.CenterX = 0;
                cameraspin.CenterY = anakamera.Position.Y;
                cameraspin.CenterZ = 0;
                (anakamera.Transform as MatrixTransform3D).Matrix *= cameraspin.Value;
            }

            if (e.Key == Key.Right)
            {
                RotateTransform3D cameraspin = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), -10));
                cameraspin.CenterX = 0;

                cameraspin.CenterY = anakamera.Position.Y;

                cameraspin.CenterZ = 0;

                (anakamera.Transform as MatrixTransform3D).Matrix *= cameraspin.Value;

            }

            if (e.Key == Key.Up)
            {
                anakamera.Position = new Point3D(anakamera.Position.X, anakamera.Position.Y, anakamera.Position.Z - 0.1D);

            }

            if (e.Key == Key.Down)
            {
                anakamera.Position = new Point3D(anakamera.Position.X, anakamera.Position.Y, anakamera.Position.Z + 0.1D);
            }
            #endregion
        }
    }
        #endregion
}

I am trying to use the keyboard arrows to move the camera but my Key_Down event isn’t firing.
is there anyway i can achieve this?
Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:59:29+00:00Added an answer on May 23, 2026 at 8:59 pm

    i used this ShowMoveButtons="{Binding ElementName=ShowMoveButtonsCheckBox, Path=IsChecked}". then the problem is solved

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have below XAML code : <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml DataContext={Binding RelativeSource={RelativeSource Self}} WindowStartupLocation=CenterScreen
XAML code is below <Window x:Class=DenemeWpfApplication1.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow Height=350 Width=525> <Grid> <DockPanel Width=Auto
The following xaml code works: <Window x:Class=DerivedTemplateBug.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:local=clr-namespace:DerivedTemplateBug Title=Window1 Height=300 Width=300> <Button>
Here's my XAML code: <Window x:Class=CarFinder.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=Search for cars in TuMomo Height=480
My XAML code is like this: <Window xmlns ='http://schemas.microsoft.com/netfx/2007/xaml/presentation' xmlns:x ='http://schemas.microsoft.com/winfx/2006/xaml' Title ='Print Preview
I have a string representation of a XAML Grid like this: <Grid xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation> <Canvas
What we ideally need is, to know how Microsoft handles XAML generated code (Those
I have a Mediaplayer control on my XAML page like below: <CustomMediaElement:CustomMediaPlayer x:Name=custMediaElement VerticalAlignment=Center
The XAML code below works fine except I want the expander button to be
I'm having a problem with the default Button in the xaml code below: <Window

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.