我目前正试图弄清楚如何让WPF设计师正确显示我可以使用的资源列表。
例如,在xaml中使用OnCreate()
时,我可以预览"可用的资源,通常。
从外部DLL /程序集(二进制文件)使用它时似乎不能正常工作。
我已经尝试使用public class RecordView : Fragment
{
private Bundle _bundle;
private ViewGroup _container;
private LayoutInflater _inflater;
ViewGroup _thisView;
TextView _tvTitle, _tvField1, _tvField2;
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle)
{
base.OnCreateView(inflater, container, bundle);
_inflater = inflater;
_container = container;
_bundle = bundle;
Render();
return _thisView;
}
public override void Render()
{
_thisView = (ViewGroup) _inflater.Inflate(Resource.Layout.Record, _container, false);
_tvTitle = _thisView.FindViewById<TextView>(Resource.Id.tv_title);
_tvField1 = _thisView.FindViewById<TextView>(Resource.Id.tv_field_1);
_tvField2 = _thisView.FindViewById<TextView>(Resource.Id.tv_field_2);
// *A* SOMETIMES WORKS - Title & fields sometimes blank
UpdateView();
// *B* SOMETIMES WORKS - Title & fields sometimes blank
_thisView.Post(() => { UpdateView(); });
}
public override void OnResume()
{
base.OnResume();
// *C* SOMETIMES WORKS - Title & fields sometimes blank
UpdateView();
// *D* ALWAYS WORKS - Title & fields always display data as expected
_thisView.Post(() => { UpdateView(); });
}
private void UpdateView()
{
_tvTitle.Text = "Todo";
_tvField1.Text = "RTFM";
_tvField2.Text = "ASAP";
}
}
的常用源字符串,
TextBlock
在搜索此问题时,在其他各种问题和答案中提到了这一点,但即使直接ResourceDictionary
到所需的<ResourceDictionary Source="pack://application:,,,/MyAssembly;component/Themes/Generic.xaml"/>
<ResourceDictionary Source="/MyAssembly;component/Themes/Generic.xaml"/>
似乎也无效。
此问题是否有任何解决方法,或者根本不起作用?
我不想禁用设计师,请不要这么做。