Cancel
Showing results for 
Search instead for 
Did you mean: 

TxObjectGridControl not showing correctly in WPF

Creator
Creator

Hello,

 

so im kinda new to Tecnomatix Development and would like to create a WPF application with MVVM.

Im adding a TxObjectGridControl to my View but it doesnt show correctly. The Header is missing and the field (which becomes green after Clicking in Process Simulate) doesn't show. When using the Command in Process Simulate I can't pick a Object.  Below you can see the code of my View and my Style resource.

        <tx:TxObjectGridControl Grid.Row="2" 
                                ItemsSource="{Binding SensorCollec}"            
                                Style="{DynamicResource TxObjGridStyle}"
                                ChangeGeneralSelection="False" 
                                CurrentRow="-1" 
                                EnableRecurringObjects="False" 
                                ListenToPick="False" 
                                ReadOnly="False"
                                ValidatorType="Component" 
                                PickLevel="Component" 
                                HorizontalAlignment="Left"/> 
    <Style TargetType="{x:Type tx:TxObjectGridControl}" x:Key="TxObjGridStyle">
        <Setter Property="FontFamily" Value="Consolas"/>
        <Setter Property="FontSize" Value="12"/>
        <Setter Property="Margin" Value="10"/>
        <Setter Property="Height" Value="120"/>
        <Setter Property="Width" Value="100"/>
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
    </Style>

Image of the GridControl:Unbenannt.PNGRegards

romox

4 REPLIES

Betreff: TxObjectGridControl not showing correctly in WPF

Creator
Creator

While waiting I did a little workaroung for my problem, i want to share with you.

So I've created my own UserControl element with following code:

    <Grid>
        <WindowsFormsHost>
            <Wtx:TxObjGridCtrl x:Name="TxObjCtrl"
                               ChangeGeneralSelection="False"
                               CurrentRow="-1"
                               EnableMultipleSelection="True"
                               EnableRecurringObjects="False"
                               ListenToPick="False"
                               PickLevel="Component"
                               ReadOnly="False"
                               ValidatorType="Component"/>
        </WindowsFormsHost>
    </Grid>

So I'm hosting the WinForms TxObjGridCtrl and declare a dependency property inside the Code behind:

 

    public partial class BindableHost : UserControl
    {
        public BindableHost()
        {
            InitializeComponent();
            TxObjCtrl.ObjectDeleting += TxObjCtrl_ObjectDeleting;
            TxObjCtrl.ObjectInserted += TxObjCtrl_ObjectInserted;
        }

         ~BindableHost()
        {
            TxObjCtrl.ObjectDeleting -= TxObjCtrl_ObjectDeleting;
            TxObjCtrl.ObjectInserted -= TxObjCtrl_ObjectInserted;
        }

         public static readonly DependencyProperty ObjectsProperty = DependencyProperty.Register(
     "ObjList",
     typeof(TxObjectList),
     typeof(BindableHost), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, ObjectsChanged));

         public TxObjectList ObjList
         {
             get { return (TxObjectList)GetValue(ObjectsProperty); }
             set { SetValue(ObjectsProperty, value); }
         }

        void TxObjCtrl_ObjectInserted(object sender, TxObjGridCtrl_ObjectInsertedEventArgs args)
        {
            ObjList = TxObjCtrl.Objects;
        }

        void TxObjCtrl_ObjectDeleting(object sender, TxObjGridCtrl_ObjectDeletingEventArgs args)
        {
            ObjList = TxObjCtrl.Objects;
        }

        private static void ObjectsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue != e.OldValue)
            {
                (d as BindableHost).TxObjCtrl.Objects = e.NewValue as TxObjectList;
            }
        }
    }
}

After all this I can use the BindableHost inside my MainView Binding against the Objects property of TxObjGridCtrl.

 

Though it's just a workaround i'll mark this as the solution. Improvements are welcome! 

 

Regards

romox

Re: TxObjectGridControl not showing correctly in WPF

Valued Contributor
Valued Contributor

Hi, romox!

 

Please check, that you refer to Tecnomatix.Engineering.Ui.WPF namespace in XAMl and not to Tecnomatix.Engineering.Ui.

if you refer to Tecnomatix.Engineering.Ui, you get the Windows Forms controls and you need to have a WindowsFormsHost to get control work properly.

Witalij.

Re: TxObjectGridControl not showing correctly in WPF

Creator
Creator

Hi Witalij,

 

I did refer to the Tecnomatix.Engineering.Ui.WPF namespace. Otherwise all WPF Controls wouldn't work. I only used the WinFormsHost for the TxObjectGridControl, because the WPF TxObjectGridControl didn't appear correctly and i could not select anything. (See question)

 

Regards,

romox

Re: TxObjectGridControl not showing correctly in WPF

Siemens Phenom Siemens Phenom
Siemens Phenom

Hi romox,

 

I know that post was added few month ago, but can you check whether the style or the binding is causing the problem that you describe?

 

Best Regards,

DianaG