I have used the DataGrid inside the usercontrol and update the data of DataGrid in timer tick by random data. If I use this usercontrol
in TabControl SelectedContent, measure override called unnecessarily until resize.
usercontrol:
<Grid><DataGridItemsSource="{Binding Rows}"/></Grid>
mainwindow:
<mytabcontrol ><TabItemHeader="Tab"><local:myusercontrol ></local:myusercontrol></TabItem></mytabcontrol>
viewmodel:
publicsealedclassViewModel{privatereadonlyDispatcherTimer _dispatcherTimer =newDispatcherTimer{Interval=TimeSpan.FromMilliseconds(250)};publicViewModel(){Rows=newObservableCollection<DataRow>();for(int i =1; i <=250;++i)Rows.Add(newDataRow(i));
_dispatcherTimer.Tick+=DispatcherTimer_Tick;
_dispatcherTimer.Start();}publicObservableCollection<DataRow>Rows{ get;privateset;}privatevoidDispatcherTimer_Tick(object sender,EventArgs e){foreach(var row inRows)
row.Update();}}
with the viewmodel I provided datagrid's height and width remains the same for every data's.